From ca7062c3e6527054d805dede838d951333f0cea7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 14 Jan 2017 10:28:57 -0500 Subject: #5 - Users can be given CP over the MUD Currently not usable in the UI, but will be used to power shops. --- ShiftOS.Objects/Shop.cs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ShiftOS.Objects/Shop.cs (limited to 'ShiftOS.Objects/Shop.cs') diff --git a/ShiftOS.Objects/Shop.cs b/ShiftOS.Objects/Shop.cs new file mode 100644 index 0000000..d20fecb --- /dev/null +++ b/ShiftOS.Objects/Shop.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class Shop + { + public string Name { get; set; } + public string Description { get; set; } + public List Items { get; set; } + } + + public abstract class ShopItem + { + public string Name { get; set; } + public string Description { get; set; } + public int Cost { get; set; } + public string ShopOwner { get; set; } + + + protected abstract void OnBuy(); + + protected abstract void GiveCPToShopOwner(int cp); + + public bool Buy(ref Save buyer) + { + if(buyer.Codepoints >= Cost) + { + buyer.Codepoints -= Cost; + OnBuy(); + GiveCPToShopOwner(Cost); + return true; + } + else + { + return false; + } + } + } +} -- cgit v1.2.3