Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jzeiber committed Nov 8, 2023
1 parent 2ae6e49 commit cb4eeef
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 24 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Use button 2 on the controller to cycle through actions
Use direction buttons to move around or access sub menus/scroll on some screens

## General Notes
When it's your turn you will see an hour glass and time left in the lower right of the screen

You can only move units and perform most actions that affect the world when it's your turn

When it's not your turn you can scroll around the map and see details about your cities

Units in cities get a 50% defense bonus (additive)

Veteran units receive a +1 attack and +1 defense modifier (before any bonus is applied)
Expand All @@ -32,8 +38,12 @@ Selecting building "None" in a city production will convert 50% of excess resour

Cities will auto select which surrounding tiles to gather resources from. Food production is prioritized first.

The game is auto saved after every complete game turn (after the last player ends their turn)

Only player 1 can start a new game / load a game

## City Improvements
Granary - Doubles storage space of food in a city
Granary - Doubles storage space of food in a city and allows city expanding beyond a population of 8

Barracks - New units created in this city will receive veteran status

Expand All @@ -45,7 +55,7 @@ Factory - Increases resource production by 50% (additive)

City Walls - Increases defense of units in city by 50% (additive)

Aqueduct - Allows city expanding beyond a population of 10
Aqueduct - Allows city expanding beyond a population of 15 (must have granary as well for population growth)

## Limitations
- 4 Civilizations
Expand All @@ -54,7 +64,11 @@ Aqueduct - Allows city expanding beyond a population of 10
- No fog of war
- No Science/Tech tree
- No government
- No sentry/fotifications/goto
- No sentry/fotifications/goto for units
- No diplomacy
- No trade routes
- No roads/land improvements
- No pollution
- Taxes are fixed at 7%
- No population happiness
- No air units
Expand Down
2 changes: 1 addition & 1 deletion bundle/index.html

Large diffs are not rendered by default.

Binary file modified cart/cart.wasm
Binary file not shown.
29 changes: 24 additions & 5 deletions src/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void Game::EndGameTurn()
m_gamedata.m_city[i].food=CityGrowthFoodRequired(i)/2;
}

// check if we have enough food to expand city (beyond 10 needs aqueduct)
// check if we have enough food to expand city
if(m_gamedata.m_city[i].food>=CityGrowthFoodRequired(i))
{
if(CityCanExpand(i)==true)
Expand Down Expand Up @@ -641,12 +641,14 @@ bool Game::CityCanExpand(const int32_t cityidx) const
{
if(cityidx>=0 && cityidx<countof(m_gamedata.m_city))
{
// ok to expand if population <10 or have aqueduct and population <25
// ok to expand if population <8 or population<15 and have granary or population<25 and have aqueduct and granary
if(m_gamedata.m_city[cityidx].population>0 &&
(
(m_gamedata.m_city[cityidx].population<10)
(m_gamedata.m_city[cityidx].population<8)
||
(m_gamedata.m_city[cityidx].population<25 && (m_gamedata.m_city[cityidx].improvements & (0x01 << IMPROVEMENT_AQUEDUCT)) == (0x01 << IMPROVEMENT_AQUEDUCT))
(m_gamedata.m_city[cityidx].population<15 && (m_gamedata.m_city[cityidx].improvements & (0x01 << IMPROVEMENT_GRANARY)) == (0x01 << IMPROVEMENT_GRANARY))
||
(m_gamedata.m_city[cityidx].population<25 && (m_gamedata.m_city[cityidx].improvements & (0x01 << IMPROVEMENT_GRANARY)) == (0x01 << IMPROVEMENT_GRANARY) && (m_gamedata.m_city[cityidx].improvements & (0x01 << IMPROVEMENT_AQUEDUCT)) == (0x01 << IMPROVEMENT_AQUEDUCT))
)
)
{
Expand Down Expand Up @@ -1071,7 +1073,24 @@ bool Game::MoveUnit(const uint8_t playerindex, const int32_t unitindex, const in
u->movesleft=0;
}
trymove=false;
// TODO - chance to reduce population or destory improvement

// chance to reduce population or destory improvement
// if our attack 1 or more greater than defense, then chance to destroy improvement
// if our attack was 2 or more greater than defense, then chance to reduce population
if(ec && ec->population>0)
{
if(att>def+1.0 && rand.NextDouble()<0.1)
{
// now get a random improvement (city may or may not have the improvement, so less chance improvements are destoryed the fewer there are)
const int32_t ii=rand.NextDouble()*IMPROVEMENT_MAX;
ec->improvements=ec->improvements & ~(0x01 << ii);
}
if(att>def+2.0 && rand.NextDouble()<0.1)
{
ec->population--;
}
}

}

ostr << " def died df=" << eu->flags;
Expand Down
26 changes: 12 additions & 14 deletions src/src/stategame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool StateGame::HandleInput(const Input *input, const uint8_t playerindex)
case ICON_VIEWMAP:
{
m_view=VIEW_MAP;
m_menuidx=-1;
m_menuidx=0; // only close button available, so have it selected
m_selecttype=SELECT_NONE;
break;
}
Expand Down Expand Up @@ -486,7 +486,7 @@ void StateGame::Draw(const uint8_t playerindex)
DrawCivData(playerindex);
break;
case VIEW_CITYDETAIL:
DrawCityDetail();
DrawCityDetail(playerindex);
break;
default:
DrawMainView(playerindex);
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void StateGame::DrawCivData(const uint8_t playerindex)

}

void StateGame::DrawCityDetail()
void StateGame::DrawCityDetail(const uint8_t playerindex)
{
int32_t xpos=0;
TextPrinter tp;
Expand All @@ -1132,6 +1132,14 @@ void StateGame::DrawCityDetail()

City *c=&(m_game->GetGameData().m_city[m_selectidx]);

// city might have been destoryed or captured while we're in this screen, so check and set back to view none
if(c->population==0 || c->owner!=m_game->PlayerCivIndex(playerindex))
{
m_view=VIEW_NONE;
m_selectidx=-1;
return;
}

tp.PrintCentered(cityname[m_selectidx],56,0,100,PALETTE_CYAN);
ostr << "Pop " << c->population;
tp.Print(ostr.Buffer(),96,0,10,PALETTE_WHITE);
Expand Down Expand Up @@ -1186,7 +1194,7 @@ void StateGame::DrawCityDetail()
{
if((c->improvements & (0x01 << i)) == (0x01 << i))
{
// TODO - print improvement name
// print improvement name
tp.Print(improvementdata[i].name,96,sy,20,PALETTE_BROWN);
// show upkeep gold if submenu is 1
if(m_submenuidx==1)
Expand All @@ -1205,14 +1213,6 @@ void StateGame::DrawCityDetail()

CityProduction prod=m_game->GetCityProduction(m_selectidx);

/*
ostr.Clear();
ostr << prod.totalfood << " " << prod.totalresources;
tp.Print(ostr.Buffer(),1,80,100,PALETTE_WHITE);
*/

*DRAW_COLORS=PALETTE_WHITE << 4 || PALETTE_BLACK;

tp.Print("Production",1,88,10,PALETTE_CYAN);

ostr.Clear();
Expand All @@ -1227,7 +1227,6 @@ void StateGame::DrawCityDetail()
ostr << prod.totalresources;
tp.Print(ostr.Buffer(),39,96,10,PALETTE_BROWN);

// TODO - based on tax rate and production
ostr.Clear();
*DRAW_COLORS=PALETTE_WHITE << 4 || PALETTE_BLACK;
blitMasked(icongfx,icongfxalpha,60,96,8,8,0,8,icongfxwidth,BLIT_1BPP);
Expand Down Expand Up @@ -1357,7 +1356,6 @@ void StateGame::DrawCityDetail()
}
}

// TODO - print resource usage of unit type
xpos+=18;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/stategame.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class StateGame:public IPlayerState
void DrawMainView(const uint8_t playerindex);
void DrawMap(const uint8_t playerindex);
void DrawCivData(const uint8_t playerindex);
void DrawCityDetail();
void DrawCityDetail(const uint8_t playerindex);
void DrawHourGlass(const uint8_t playerindex);

void PrintInfo(const char *text, const int32_t cx, const int32_t y, const int32_t len, const int32_t fg, const int32_t bg);
Expand Down

0 comments on commit cb4eeef

Please sign in to comment.