jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

TODO: allow players to sell items to server #31

Closed jpcsupplies closed 8 years ago

jpcsupplies commented 9 years ago

Need the ability for a player to sell a chosen item and qty back to the server in exchange for its listed value

eg /value iron ore
(replies 2ea) /sell 20 iron ore (removes 20 iron ore from their inventory and pays them 40)

optionally the amount they get paid is deducted from the balance of an NPC player in the bank file eg Merchant So we will need to create a fake bank entry for the "merchant" this will be paid to and drawn from when players transact with the server. Once we transition to global commodity market the merchant account will behave like a trader that always lists at the same price (based on price table) that way at least one merchant is always active even if its the server itself

long term keep track of available supply of resources too in order to transition to the global market later

jpcsupplies commented 8 years ago

Making painfully slow progress.. but with two kids running around screaming its a wonder it even loaded without errors lol..

The create NPC account bit works tho, but the fact i used the reset command logic makes it a rather messy bit of code. Im out of the code for the night if you want to trim the fat, i expect the process server part or the protocontract is probably not needed in my create NPC, but it does write a message to game if an NPC had to be created MyAPIGateway.Utilities.ShowMessage("Banker", "Created"); and down the line the same section might be used for creating the faction/player trade markets?

have to see how things progress - so far about the only useful thing i have been able to use from my old IT software development training is designing the milestones, I seem to be sucking at the coding part :(

jpcsupplies commented 8 years ago

@midspace Ok, code should make some sort of sense now. Although my regex filter is basically a guess at the moment. I am just pondering if i should focus on player to player trade first, or the player to NPC table.

Both seem similar complexity. /sell all iron 0.5 "Screaming Angel" logic

/sell all iron logic

Will hold off the "global market "offer table"" till next release, and price logic is used player-player anyway, so we need only worry about player to player trades or selling to the price table at 0.0.0

I m thinking in line with our previous release focusing on player interaction the player to player should be the priority, since the lack of a /buy command is irrelevant.then.

jpcsupplies commented 8 years ago

@midspace Having trouble building my sell regex - refer notes in code - can i get an assist :)

midspace commented 8 years ago

Sorry, I've been very busy building a new mining ship on the server. BTW, someone played demolition derby on the inside of the station. Lots of ship parts drifting about. I'll have a look at it tomorrow evening. Work has me busy this week.

jpcsupplies commented 8 years ago

oh well at least players cant complain we didnt leave enough spare parts.. on the up side the /accounts list will probably tell us who logged on recently.....

jpcsupplies commented 8 years ago

any way we can use this to discriminate material type, for our qty checks? var physicalItems = MyDefinitionManager.Static.GetPhysicalItemDefinitions();

midspace commented 8 years ago

any way we can use this to discriminate material type, for our qty checks?

yes. To a degree we're already checking the material types in the MessageSell.ProcessServer(). https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/Messages/MessageSell.cs

I intend to move those validations into ProcessServer(), as this will better encapsulate the functionality if we extend it later into an API, and it reduces the potential for hackers misusing it, as it will do it's own validation instead of relying upon validation prior to it running.

midspace commented 8 years ago

I've like to move the RangeCheck into the ProcessServer also.

SaltPepp commented 8 years ago

I've been thinking.... An idea I thought of is that you can trade items for items. This could be a bool setting if true, this feature is enabled.

Sent from my Windows Phone


From: midspacemailto:notifications@github.com Sent: ‎30/‎09/‎2015 12:21 PM To: jpcsupplies/Economy_modmailto:Economy_mod@noreply.github.com Subject: Re: [Economy_mod] TODO: allow players to sell items to server (#31)

any way we can use this to discriminate material type, for our qty checks?

yes. To a degree we're already checking the material types in the MessageSell.ProcessServer(). https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/Messages/MessageSell.cs

I intend to move those validations into ProcessServer(), as this will better encapsulate the functionality if we extend it later into an API, and it reduces the potential for hackers misusing it, as it will do it's own validation instead of relying upon validation prior to it running.


Reply to this email directly or view it on GitHub: https://github.com/jpcsupplies/Economy_mod/issues/31#issuecomment-144261452

jpcsupplies commented 8 years ago

Game already works like that now in effect @SaltPepp without an economy players would trade materials with each other. However the economy mod can work similarly; you just send an offer to sell goods to a player for free, then hope they send the goods free back in return. The idea had occurred to me in passing. In financial market terms its considered barter or tether type trade.

re: rangecheck @midspace I always assumed we would be moving that stuff out of the main file, as we did with the other commands, I considered making it in another file, but while it is a placeholder didnt think it would matter yet; and was undecided which would be the best place as rangecheck can be used for other stuff too potentially.

jpcsupplies commented 8 years ago

All underlying error checks, pricing lookups, item transfers, and payment technologies for this command are now in place. Sell command to sell to server is now fully operational within the stated aims of this milestone. Good Work Everyone. May still be bugs, but basic functionality is ready to go.