prevent buying the 'high level' commodities at market
This commit is contained in:
@@ -47,7 +47,7 @@ All computers you will use to play must be connected to the same Wi-Fi network.
|
|||||||
1. connect a computer to your main TV/projector screen. This will be your "server." Run the server binary
|
1. connect a computer to your main TV/projector screen. This will be your "server." Run the server binary
|
||||||
2. you can press `TAB` on the server to switch between Debug and Map. Map is the main game-view.
|
2. you can press `TAB` on the server to switch between Debug and Map. Map is the main game-view.
|
||||||
3. have each player run their `client` application. It will prompt them for the `Server IP Address`, which should be displayed in the top right corner of the server.
|
3. have each player run their `client` application. It will prompt them for the `Server IP Address`, which should be displayed in the top right corner of the server.
|
||||||
4. Don't bother with secure passwords when logging. The password is just to prevent your brother from trying to login as you.
|
4. Don't bother with secure passwords when logging in. The password is just to prevent your brother from trying to login as you.
|
||||||
5. Wait until each player has selected their ship and sees the "Map" tab on their screen.
|
5. Wait until each player has selected their ship and sees the "Map" tab on their screen.
|
||||||
6. Start playing!
|
6. Start playing!
|
||||||
|
|
||||||
|
|||||||
+12
-4
@@ -1328,8 +1328,8 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
|||||||
renderStrToBuffer(tui->frame_buffer, box.x+2, yoff++, sbuf, screen_dimensions);
|
renderStrToBuffer(tui->frame_buffer, box.x+2, yoff++, sbuf, screen_dimensions);
|
||||||
yoff++;
|
yoff++;
|
||||||
|
|
||||||
bool player_has_money_for_purchase = state->me.credits > curr.auction.price;
|
bool player_has_money_for_purchase = state->me.credits >= curr.auction.price;
|
||||||
bool player_has_cargo_space_for_purchase = (state->me.vacuum_cargo_slots - usedVacuumCargoSlots(state->me)) > curr.auction.qty;
|
bool player_has_cargo_space_for_purchase = (state->me.vacuum_cargo_slots - usedVacuumCargoSlots(state->me)) >= curr.auction.qty;
|
||||||
if (player_has_money_for_purchase && player_has_cargo_space_for_purchase) {
|
if (player_has_money_for_purchase && player_has_cargo_space_for_purchase) {
|
||||||
const char* label = "ACCEPT OFFER [ENTER]";
|
const char* label = "ACCEPT OFFER [ENTER]";
|
||||||
Range1u32 range = {
|
Range1u32 range = {
|
||||||
@@ -1446,7 +1446,11 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
|||||||
rows[i].type = c.type;
|
rows[i].type = c.type;
|
||||||
rows[i].unit = c.unit;
|
rows[i].unit = c.unit;
|
||||||
rows[i].bid = priceForCommodity(i, qty, true);
|
rows[i].bid = priceForCommodity(i, qty, true);
|
||||||
|
if (i > AUCTION_COMMODITY_CUTOFF) {
|
||||||
|
rows[i].ask = 0;
|
||||||
|
} else {
|
||||||
rows[i].ask = priceForCommodity(i, qty, false);
|
rows[i].ask = priceForCommodity(i, qty, false);
|
||||||
|
}
|
||||||
rows[i].qty = qty;
|
rows[i].qty = qty;
|
||||||
rows[i].owned = state->me.commodities[i];
|
rows[i].owned = state->me.commodities[i];
|
||||||
}
|
}
|
||||||
@@ -1463,7 +1467,8 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
|||||||
// common/shared variables
|
// common/shared variables
|
||||||
bool buy_selected = state->modal_choice.selected_index == 0;
|
bool buy_selected = state->modal_choice.selected_index == 0;
|
||||||
u32 y_off = modal_outline.y+2;
|
u32 y_off = modal_outline.y+2;
|
||||||
str cname = COMMODITIES[state->row.selected_index].name;
|
Commodity current_commodity = COMMODITIES[state->row.selected_index];
|
||||||
|
str cname = current_commodity.name;
|
||||||
|
|
||||||
switch (state->market_tab_state) {
|
switch (state->market_tab_state) {
|
||||||
case MarketTabStateTable: {
|
case MarketTabStateTable: {
|
||||||
@@ -1480,7 +1485,6 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
|||||||
if (user_pressed_backspace) {
|
if (user_pressed_backspace) {
|
||||||
state->market_tab_state = MarketTabStateTable;
|
state->market_tab_state = MarketTabStateTable;
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
} break;
|
} break;
|
||||||
case MarketTabStateTransact: {
|
case MarketTabStateTransact: {
|
||||||
if (user_pressed_right) {
|
if (user_pressed_right) {
|
||||||
@@ -1498,7 +1502,11 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
|||||||
renderStrToBuffer(tui->frame_buffer, modal_outline.x+(modal_outline.width/2)-strlen(cname), modal_outline.y+1, cname, screen_dimensions);
|
renderStrToBuffer(tui->frame_buffer, modal_outline.x+(modal_outline.width/2)-strlen(cname), modal_outline.y+1, cname, screen_dimensions);
|
||||||
u32 buy_x = modal_outline.x+2;
|
u32 buy_x = modal_outline.x+2;
|
||||||
u32 sell_x = modal_outline.x+modal_outline.width-6;
|
u32 sell_x = modal_outline.x+modal_outline.width-6;
|
||||||
|
if (current_commodity.type < AUCTION_COMMODITY_CUTOFF) {
|
||||||
renderStrToBuffer(tui->frame_buffer, buy_x, y_off, "Buy", screen_dimensions);
|
renderStrToBuffer(tui->frame_buffer, buy_x, y_off, "Buy", screen_dimensions);
|
||||||
|
} else {
|
||||||
|
buy_selected = false;
|
||||||
|
}
|
||||||
renderStrToBuffer(tui->frame_buffer, sell_x, y_off, "Sell", screen_dimensions);
|
renderStrToBuffer(tui->frame_buffer, sell_x, y_off, "Sell", screen_dimensions);
|
||||||
if (buy_selected) {
|
if (buy_selected) {
|
||||||
u32 pos = XYToPos(buy_x, y_off, tui->screen_dimensions.width);
|
u32 pos = XYToPos(buy_x, y_off, tui->screen_dimensions.width);
|
||||||
|
|||||||
+42
-1
@@ -1074,7 +1074,7 @@ fn void* gameLoop(void* params) {
|
|||||||
f32 t_sec = ((f32)state.frame - (f32)grace_period_ends_at) / (f32)GOAL_GAME_LOOPS_PER_S;
|
f32 t_sec = ((f32)state.frame - (f32)grace_period_ends_at) / (f32)GOAL_GAME_LOOPS_PER_S;
|
||||||
// t is in minutes
|
// t is in minutes
|
||||||
f32 t = t_sec / 60;
|
f32 t = t_sec / 60;
|
||||||
f32 decay = -0.50 * t;
|
f32 decay = -0.60 * t;
|
||||||
f32 floor_price = COMMODITIES[sys->auction.type].price * 0.9;
|
f32 floor_price = COMMODITIES[sys->auction.type].price * 0.9;
|
||||||
sys->auction.price = Max((initial_price * pow(EULERS_E, decay)), floor_price);
|
sys->auction.price = Max((initial_price * pow(EULERS_E, decay)), floor_price);
|
||||||
}
|
}
|
||||||
@@ -1513,9 +1513,50 @@ i32 main(i32 argc, ptr argv[]) {
|
|||||||
state.map[i].auction.qty = COMMODITIES[state.map[i].auction.type].consumption;
|
state.map[i].auction.qty = COMMODITIES[state.map[i].auction.type].consumption;
|
||||||
// setup the planets
|
// setup the planets
|
||||||
u32 planet_count = rand() % MAX_PLANETS + 1;
|
u32 planet_count = rand() % MAX_PLANETS + 1;
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
addSystemMessage((u8*)"Vega Earth Gas");
|
||||||
|
planet_count = 2;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeEarth;
|
||||||
|
state.map[i].planets[1].type = PlanetTypeGas;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
addSystemMessage((u8*)"Aldebara Earth Earth Asteroid");
|
||||||
|
planet_count = 3;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeEarth;
|
||||||
|
state.map[i].planets[1].type = PlanetTypeEarth;
|
||||||
|
state.map[i].planets[2].type = PlanetTypeAsteroid;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
addSystemMessage((u8*)"Mining Colony 17 Asteroid");
|
||||||
|
planet_count = 1;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeAsteroid;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
planet_count = 2;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeGas;
|
||||||
|
state.map[i].planets[1].type = PlanetTypeMoon;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
planet_count = 3;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeStation;
|
||||||
|
state.map[i].planets[1].type = PlanetTypeAsteroid;
|
||||||
|
state.map[i].planets[2].type = PlanetTypeAsteroid;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
planet_count = 2;
|
||||||
|
state.map[i].planets[0].type = PlanetTypeStation;
|
||||||
|
state.map[i].planets[1].type = PlanetTypeMoon;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (u32 ii = 0; ii < planet_count; ii++) {
|
for (u32 ii = 0; ii < planet_count; ii++) {
|
||||||
Planet* p = &state.map[i].planets[ii];
|
Planet* p = &state.map[i].planets[ii];
|
||||||
|
if (p->type == PlanetTypeNull) {
|
||||||
|
addSystemMessage((u8*)"random planet type");
|
||||||
p->type = 1+(PlanetType)(rand() % (PlanetType_Count -1));
|
p->type = 1+(PlanetType)(rand() % (PlanetType_Count -1));
|
||||||
|
}
|
||||||
// default commodity + production roll
|
// default commodity + production roll
|
||||||
for (u32 iii = 0; iii < Commodity_Count; iii++) {
|
for (u32 iii = 0; iii < Commodity_Count; iii++) {
|
||||||
p->commodities[iii] = (COMMODITIES[iii].qty / 5) + (rand() % COMMODITIES[iii].qty);
|
p->commodities[iii] = (COMMODITIES[iii].qty / 5) + (rand() % COMMODITIES[iii].qty);
|
||||||
|
|||||||
+9
-9
@@ -15,7 +15,7 @@
|
|||||||
#define MAX_PASSENGER_JOB_PEOPLE (4)
|
#define MAX_PASSENGER_JOB_PEOPLE (4)
|
||||||
#define MAX_PASSENGER_JOB_PRICE (10000)
|
#define MAX_PASSENGER_JOB_PRICE (10000)
|
||||||
#define MAX_PASSENGER_BERTHS (8)
|
#define MAX_PASSENGER_BERTHS (8)
|
||||||
#define AUCTION_COMMODITY_CUTOFF (6)
|
#define AUCTION_COMMODITY_CUTOFF (7)
|
||||||
#define AUCTION_PRICE_START_MULTIPLE (12)
|
#define AUCTION_PRICE_START_MULTIPLE (12)
|
||||||
|
|
||||||
typedef enum ShipType {
|
typedef enum ShipType {
|
||||||
@@ -161,35 +161,35 @@ global Commodity COMMODITIES[Commodity_Count] = {
|
|||||||
},
|
},
|
||||||
{ .type = CommodityRawTextiles, .unit = StorageUnitContainer,
|
{ .type = CommodityRawTextiles, .unit = StorageUnitContainer,
|
||||||
.name = "Raw Textiles",
|
.name = "Raw Textiles",
|
||||||
.price = 500, .qty = 40, .consumption = 3,
|
.price = 400, .qty = 40, .consumption = 3,
|
||||||
},
|
},
|
||||||
{ .type = CommodityOre, .unit = StorageUnitContainer,
|
{ .type = CommodityOre, .unit = StorageUnitContainer,
|
||||||
.name = "Ore",
|
.name = "Ore",
|
||||||
.price = 1000, .qty = 100, .consumption = 8,
|
.price = 600, .qty = 100, .consumption = 8,
|
||||||
},
|
},
|
||||||
{ .type = CommodityPlastics, .unit = StorageUnitContainer,
|
{ .type = CommodityPlastics, .unit = StorageUnitContainer,
|
||||||
.name = "Plastics",
|
.name = "Plastics",
|
||||||
.price = 2000, .qty = 30, .consumption = 5,
|
.price = 800, .qty = 30, .consumption = 5,
|
||||||
},
|
},
|
||||||
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
|
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
|
||||||
.name = "Semi-conductors",
|
.name = "Semi-conductors",
|
||||||
.price = 4000, .qty = 40, .consumption = 3,
|
.price = 1000, .qty = 40, .consumption = 3,
|
||||||
},
|
},
|
||||||
{ .type = CommodityMetals, .unit = StorageUnitContainer,
|
{ .type = CommodityMetals, .unit = StorageUnitContainer,
|
||||||
.name = "Metals",
|
.name = "Metals",
|
||||||
.price = 5000, .qty = 40, .consumption = 3,
|
.price = 2000, .qty = 30, .consumption = 3,
|
||||||
},
|
},
|
||||||
{ .type = CommodityGlass, .unit = StorageUnitContainer,
|
{ .type = CommodityGlass, .unit = StorageUnitContainer,
|
||||||
.name = "Glass",
|
.name = "Glass",
|
||||||
.price = 9200, .qty = 50, .consumption = 5,
|
.price = 4000, .qty = 30, .consumption = 3,
|
||||||
},
|
},
|
||||||
{ .type = CommodityHandTools, .unit = StorageUnitContainer,
|
{ .type = CommodityHandTools, .unit = StorageUnitContainer,
|
||||||
.name = "Hand Tools",
|
.name = "Hand Tools",
|
||||||
.price = 12000, .qty = 9, .consumption = 2,
|
.price = 5000, .qty = 30, .consumption = 3,
|
||||||
},
|
},
|
||||||
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
|
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
|
||||||
.name = "Electronics",
|
.name = "Electronics",
|
||||||
.price = 21000, .qty = 20, .consumption = 3,
|
.price = 9000, .qty = 30, .consumption = 3,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user