diff --git a/README.md b/README.md index e266631..92e2079 100644 --- a/README.md +++ b/README.md @@ -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 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. -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. 6. Start playing! diff --git a/src/client.c b/src/client.c index 5075af0..c9ebef1 100644 --- a/src/client.c +++ b/src/client.c @@ -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); yoff++; - 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_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; if (player_has_money_for_purchase && player_has_cargo_space_for_purchase) { const char* label = "ACCEPT OFFER [ENTER]"; 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].unit = c.unit; rows[i].bid = priceForCommodity(i, qty, true); - rows[i].ask = priceForCommodity(i, qty, false); + if (i > AUCTION_COMMODITY_CUTOFF) { + rows[i].ask = 0; + } else { + rows[i].ask = priceForCommodity(i, qty, false); + } rows[i].qty = qty; 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 bool buy_selected = state->modal_choice.selected_index == 0; 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) { case MarketTabStateTable: { @@ -1480,7 +1485,6 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count if (user_pressed_backspace) { state->market_tab_state = MarketTabStateTable; } - // TODO } break; case MarketTabStateTransact: { 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); u32 buy_x = modal_outline.x+2; u32 sell_x = modal_outline.x+modal_outline.width-6; - renderStrToBuffer(tui->frame_buffer, buy_x, y_off, "Buy", screen_dimensions); + if (current_commodity.type < AUCTION_COMMODITY_CUTOFF) { + 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); if (buy_selected) { u32 pos = XYToPos(buy_x, y_off, tui->screen_dimensions.width); diff --git a/src/server.c b/src/server.c index 1cfc7fc..1134bbe 100644 --- a/src/server.c +++ b/src/server.c @@ -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; // t is in minutes 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; 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; // setup the planets 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++) { Planet* p = &state.map[i].planets[ii]; - p->type = 1+(PlanetType)(rand() % (PlanetType_Count -1)); + if (p->type == PlanetTypeNull) { + addSystemMessage((u8*)"random planet type"); + p->type = 1+(PlanetType)(rand() % (PlanetType_Count -1)); + } // default commodity + production roll for (u32 iii = 0; iii < Commodity_Count; iii++) { p->commodities[iii] = (COMMODITIES[iii].qty / 5) + (rand() % COMMODITIES[iii].qty); diff --git a/src/shared.h b/src/shared.h index d1c2392..128c2bc 100644 --- a/src/shared.h +++ b/src/shared.h @@ -15,7 +15,7 @@ #define MAX_PASSENGER_JOB_PEOPLE (4) #define MAX_PASSENGER_JOB_PRICE (10000) #define MAX_PASSENGER_BERTHS (8) -#define AUCTION_COMMODITY_CUTOFF (6) +#define AUCTION_COMMODITY_CUTOFF (7) #define AUCTION_PRICE_START_MULTIPLE (12) typedef enum ShipType { @@ -161,35 +161,35 @@ global Commodity COMMODITIES[Commodity_Count] = { }, { .type = CommodityRawTextiles, .unit = StorageUnitContainer, .name = "Raw Textiles", - .price = 500, .qty = 40, .consumption = 3, + .price = 400, .qty = 40, .consumption = 3, }, { .type = CommodityOre, .unit = StorageUnitContainer, .name = "Ore", - .price = 1000, .qty = 100, .consumption = 8, + .price = 600, .qty = 100, .consumption = 8, }, { .type = CommodityPlastics, .unit = StorageUnitContainer, .name = "Plastics", - .price = 2000, .qty = 30, .consumption = 5, + .price = 800, .qty = 30, .consumption = 5, }, { .type = CommoditySemiConductors, .unit = StorageUnitContainer, .name = "Semi-conductors", - .price = 4000, .qty = 40, .consumption = 3, + .price = 1000, .qty = 40, .consumption = 3, }, { .type = CommodityMetals, .unit = StorageUnitContainer, .name = "Metals", - .price = 5000, .qty = 40, .consumption = 3, + .price = 2000, .qty = 30, .consumption = 3, }, { .type = CommodityGlass, .unit = StorageUnitContainer, .name = "Glass", - .price = 9200, .qty = 50, .consumption = 5, + .price = 4000, .qty = 30, .consumption = 3, }, { .type = CommodityHandTools, .unit = StorageUnitContainer, .name = "Hand Tools", - .price = 12000, .qty = 9, .consumption = 2, + .price = 5000, .qty = 30, .consumption = 3, }, { .type = CommodityElectronics, .unit = StorageUnitContainer, .name = "Electronics", - .price = 21000, .qty = 20, .consumption = 3, + .price = 9000, .qty = 30, .consumption = 3, }, };