deontologician / spaceship-build

Sci-fi spaceship engineering simulation
GNU Affero General Public License v3.0
5 stars 1 forks source link

Purchasing components #29

Closed deontologician closed 10 years ago

deontologician commented 10 years ago

We need a way to be able to purchase components.

I propose we have a "store" that you can get whatever you want from. Initially, everything will be free to aid in convenience.

Once we get more to the game portion we can do things like adding money into the equation.

Example:

> purchase cable-tube
cable-tube purchased and added to inventory.

This also relates to the player's inventory #30 . We need one of those too.

Basic sketch of how this might work:

We need some kind of Registry that holds every kind of thing that can be purchased, along with a simple name like cable-tube in the example above that uniquely identifies that kind of thing.

Then we need the purchase command in the commandline to be able to create a new thing based on what the user requested, and add it to their inventory. Again, this is dependent on #30 being done.

deontologician commented 10 years ago

Another thought: since the inventory might not be done when this is done. Assume there's an inventory object that has a method called store (think "store this for me"), and that the method accepts whatever object you want to put into it.

Dr4k3-M0nt4g commented 10 years ago

@deontologician Could the store operate as a huge list of items available? If so, then someone could just copy the stats and everything with the 'buy' command?

deontologician commented 10 years ago

Yeah, the store should have every item possible registered with it. There should be one store in existence Each time you purchase an item, you'll need to instantiate an item of that type. Probably, you'll want to store the class itself in a large dictionary:

from components import Raygun, Armor, ...
all_items = {'raygun': Raygun,
             'armor': Armor,
             ...
}
deontologician commented 10 years ago

This was partially implemented by @Dr4k3-M0nt4g , @MangroveCuckoo and I in c4b1a4c

The next steps are:

  1. Add a shop instance to the SpaceshipCommand class. Currently it has an inventory and a bus.
  2. Add a method to SpaceshipCommand called do_purchase that buys the specified item from the shop and puts it into the player's inventory