-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many fixes and additions, see description
-Inventory system almost done -Market for buying randomly generated houses -Refined jobs system -Refined factions system in preparation for adding factions such as police -Started working on item shops
- Loading branch information
Samuli Lehtonen
committed
Jan 5, 2018
1 parent
d3066c9
commit 299e774
Showing
32 changed files
with
1,294 additions
and
1,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
class HouseForSale { | ||
constructor(id, name, price, seller, buildingName) { | ||
this.id = id; | ||
this.name = name; | ||
this.price = price; | ||
this.seller = seller; | ||
this.buildingName = buildingName; | ||
} | ||
} | ||
|
||
|
||
class HouseMarketManager { | ||
constructor() { | ||
this.housesForSale = []; | ||
} | ||
|
||
initializeHouses(houseIds, houseNames, housePrices, houseSellers, houseBuildingNames) { | ||
this.housesForSale = []; | ||
for (var i = 0; i < houseIds.Count; i++) { | ||
this.housesForSale.push(new HouseForSale(houseIds[i], houseNames[i], housePrices[i], houseSellers[i], houseBuildingNames[i])); | ||
} | ||
} | ||
|
||
closeHouseMenu() { | ||
API.closeAllMenus(); | ||
} | ||
|
||
showHouseBuySellSelectMenu(houseIds, houseNames, housePrices, houseSellers, houseBuildingNames) { | ||
API.closeAllMenus(); | ||
this.initializeHouses(houseIds, houseNames, housePrices, houseSellers, houseBuildingNames); | ||
|
||
let menu = API.createMenu("LS Properties", "Options", 0, 0, 6); | ||
let item1 = API.createMenuItem("Buy properties", ""); | ||
let item2 = API.createMenuItem("Sell properties", ""); | ||
|
||
menu.BindMenuToItem(this.getMarketMenu(), item1); | ||
|
||
menu.AddItem(item1); | ||
menu.AddItem(item2); | ||
|
||
menu.Visible = true; | ||
|
||
} | ||
|
||
getUserInputForHouseName(menu, item) { | ||
var name = API.getUserInput("", 20); | ||
item.Text = "Name: " + name; | ||
} | ||
|
||
tryBuyPropertyWithId(id, name) { | ||
API.triggerServerEvent("EVENT_TRY_BUY_PROPERTY", id, name); | ||
} | ||
|
||
getBuyHouseDetailMenu(id, name, price, seller, buildingName) { | ||
let menu = API.createMenu("LS Properties", "Building: " + buildingName, 0, 0, 6); | ||
let item1 = API.createMenuItem("Seller: " + seller, ""); | ||
let item2 = API.createMenuItem("Price: $" + price.toString(), ""); | ||
let item5 = API.createMenuItem("Name: " + name, "Press to rename house"); | ||
let item4 = API.createColoredItem("Buy property", "", "#53a828", "#69d831"); | ||
item4.Activated.connect(() => this.tryBuyPropertyWithId(id, item5.Text.substring(6))); | ||
item5.Activated.connect(() => this.getUserInputForHouseName(menu, item5)); | ||
menu.AddItem(item1); | ||
menu.AddItem(item2); | ||
menu.AddItem(item5); | ||
menu.AddItem(item4); | ||
return menu; | ||
} | ||
|
||
getMarketMenu() { | ||
let menu = API.createMenu("LS Properties", "Properties for sale", 0, 0, 6); | ||
for (var i = 0; i < this.housesForSale.length; i++) { | ||
let item = API.createMenuItem(this.housesForSale[i].name, "Seller: " + this.housesForSale[i].seller); | ||
item.SetRightLabel("$ " + this.housesForSale[i].price.toString()); | ||
menu.AddItem(item); | ||
menu.BindMenuToItem(this.getBuyHouseDetailMenu(this.housesForSale[i].id, this.housesForSale[i].name, this.housesForSale[i].price, this.housesForSale[i].seller, this.housesForSale[i].buildingName), item); | ||
} | ||
return menu; | ||
} | ||
|
||
handleHouseMarketEvent(eventName, args) { | ||
if (eventName == "EVENT_OPEN_HOUSE_MARKET_MENU") { | ||
this.showHouseBuySellSelectMenu(args[0], args[1], args[2], args[3], args[4]); | ||
} | ||
else if (eventName == "EVENT_CLOSE_HOUSE_MARKET_MENU") { | ||
this.closeHouseMenu(); | ||
} | ||
} | ||
} | ||
|
||
let houseMarketManager = new HouseMarketManager(); | ||
API.onServerEventTrigger.connect((eventName, args) => houseMarketManager.handleHouseMarketEvent(eventName, args)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class ItemForSale { | ||
constructor(id, name, description, amount, price) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.amount = amount; | ||
this.price = price; | ||
} | ||
} | ||
|
||
class ItemShopManager { | ||
constructor() { | ||
this.itemsForSale = []; | ||
} | ||
|
||
handleItemShopEvent(eventName, args) { | ||
if (eventName == "EVENT_OPEN_ITEM_SHOP_MENU") { | ||
this.initializeItems(args[0], args[1], args[2], args[3], args[4]); | ||
this.createShopMenu(); | ||
} | ||
} | ||
|
||
initializeItems(ids, names, descriptions, amounts, prices) { | ||
for (var i = 0; i < ids.Count; i++) { | ||
this.itemsForSale.push(new ItemForSale(ids[i], names[i], descriptions[i], amounts[i], prices[i])); | ||
} | ||
} | ||
|
||
createShopMenu() { | ||
let menu = API.createMenu("247 Supermarket", "Options", 0, 0, 6); | ||
let item1 = API.createMenuItem("Buy items", ""); | ||
let item2 = API.createMenuItem("Sell items", ""); | ||
|
||
menu.BindMenuToItem(this.createShopBuyMenu(), item1); | ||
|
||
menu.AddItem(item1); | ||
menu.AddItem(item2); | ||
menu.Visible = true; | ||
} | ||
|
||
createShopBuyMenu() { | ||
let menu = API.createMenu("247 Supermarket", "Items on sale", 0, 0, 6); | ||
for (var i = 0; i < this.itemsForSale.length; i++) { | ||
let item = API.createMenuItem(this.itemsForSale[i].name, this.itemsForSale[i].description); | ||
item.SetRightLabel("$" + this.itemsForSale[i].price.toString()); | ||
menu.AddItem(item); | ||
} | ||
return menu; | ||
} | ||
|
||
createShopSellMenu() { | ||
|
||
} | ||
} | ||
|
||
let itemShopManager = new ItemShopManager(); | ||
API.onServerEventTrigger.connect((eventName, args) => itemShopManager.handleItemShopEvent(eventName, args)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.