Skip to content

Commit

Permalink
Added some more docs to modify.cpp.
Browse files Browse the repository at this point in the history
Also added a limitation on tactics-5 leaders -- they can now be limited based on the number of faction points allocated to war.
  • Loading branch information
anthony committed Feb 9, 2003
1 parent 5dbfba7 commit 2f6649f
Show file tree
Hide file tree
Showing 16 changed files with 390 additions and 14 deletions.
4 changes: 2 additions & 2 deletions alist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ AList::~AList()
void AList::DeleteAll()
{
AListElem * temp; ///< A temporary variable to contain the current list element.
///< Otherwise, when we delete list, we lose list->next too!
/// Otherwise, when we delete list, we lose list->next too!
while (list) {
temp = list->next;
delete list;
Expand All @@ -70,7 +70,7 @@ void AList::DeleteAll()
void AList::Empty()
{
AListElem * temp; ///< A temporary variable to contain the current list element.
///< Otherwise, when we delete list, we lose list->next too!
/// Otherwise, when we delete list, we lose list->next too!
while (list) {
temp = list->next;
list->next = 0;
Expand Down
12 changes: 10 additions & 2 deletions army.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,16 @@ Army::Army(Unit * ldr,AList * locs,int regtype,int ass)
}
}
}
tactitian->PracticeAttribute("tactics");

// If TACTICS_NEEDS_WAR is enabled, we don't want to push leaders
// from tact-4 to tact-5!
if (Globals->TACTICS_NEEDS_WAR) {
int currskill = tactitian->skills.GetDays(S_TACTICS)/tactitian->GetMen();
if (currskill < 450 - Globals->SKILL_PRACTICE_AMOUNT) {
tactitian->PracticeAttribute("tactics");
}
} else { // Only Globals->TACTICS_NEEDS_WAR == 0
tactitian->PracticeAttribute("tactics");
}
soldiers = new SoldierPtr[count];
int x = 0;
int y = count;
Expand Down
6 changes: 6 additions & 0 deletions ceran/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ static int aq[] = { 2, 3, 4, 5, 8, 12, 20 };
int *allowedQuartermasters = aq;
int allowedQuartermastersSize = sizeof(aq)/ sizeof(aq[0]);

// at is already taken up for allowedtaxes, so I'll use ag (allowedgenghises) ;)
static int ag[] = { 0, 1, 2, 4, 6, 10 };
int *allowedTacticians = ag;
int allowedTacticiansSize = sizeof(ag) / sizeof(ag[0]);

static GameDefs g = {
"Ceran", // RULESET_NAME
MAKE_ATL_VER( 3, 0, 0 ), // RULESET_VERSION
Expand Down Expand Up @@ -211,6 +216,7 @@ static GameDefs g = {
3, // DELAY_MORTALITY
6, // DELAY_GROWTH
100, // TOWN_DEVELOPMENT
0, //TACTICS_NEEDS_WAR
};

GameDefs *Globals = &g;
6 changes: 6 additions & 0 deletions conquest/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ static int aq[] = { -1 };
int *allowedQuartermasters = aq;
int allowedQuartermastersSize = sizeof(aq) / sizeof(aq[0]);

// at is already taken up for allowedtaxes, so I'll use ag (allowedgenghises) ;)
static int ag[] = { -1 };
int *allowedTacticians = ag;
int allowedTacticiansSize = sizeof(ag) / sizeof(ag[0]);

static GameDefs g = {
"Atlantis Conquest", // RULESET_NAME
MAKE_ATL_VER( 2, 0, 0 ), // RULESET_VERSION
Expand Down Expand Up @@ -210,6 +215,7 @@ static GameDefs g = {
3, // DELAY_MORTALITY
6, // DELAY_GROWTH
100, // TOWN_DEVELOPMENT
0, //TACTICS_NEEDS_WAR
};

GameDefs *Globals = &g;
4 changes: 4 additions & 0 deletions faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ void Faction::WriteReport(Areport *f, Game *pGame)
f->PutStr(AString("Quartermasters: ") + numqms + " (" +
pGame->AllowedQuarterMasters(this) + ")");
}
if (Globals->TACTICS_NEEDS_WAR) {
f->PutStr(AString("Tacticians: ") + numtacts + " (" +
pGame->AllowedTacticians(this) + ")");
}
f->PutStr(AString("Mages: ") + nummages + " (" +
pGame->AllowedMages(this) + ")");
if(Globals->APPRENTICES_EXIST) {
Expand Down
1 change: 1 addition & 0 deletions faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Faction : public AListElem
int nummages;
int numapprentices;
int numqms;
int numtacts;
AList war_regions;
AList trade_regions;

Expand Down
53 changes: 52 additions & 1 deletion game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,8 @@ void Game::WriteReport()
CountAllApprentices();
if (Globals->TRANSPORT & GameDefs::ALLOW_TRANSPORT)
CountAllQuarterMasters();

if (Globals->TACTICS_NEEDS_WAR)
CountAllTacticians();
forlist(&factions) {
Faction *fac = (Faction *) elem;
AString str = "report.";
Expand Down Expand Up @@ -1635,6 +1636,29 @@ void Game::CountAllQuarterMasters()
}
}

// This, along with counting apprentices, mages and quartermasters,
// should all be in the one function (CountSpecialists?)
void Game::CountAllTacticians()
{
forlist(&factions) {
((Faction *) elem)->numtacts = 0;
}

{
forlist(&regions) {
ARegion *r = (ARegion *) elem;
forlist(&r->objects) {
Object *o = (Object *) elem;
forlist(&o->units) {
Unit *u = (Unit *) elem;
if (u->GetSkill(S_TACTICS) == 5)
u->faction->numtacts++;
}
}
}
}
}

// LLS
void Game::UnitFactionMap()
{
Expand Down Expand Up @@ -1715,6 +1739,22 @@ int Game::CountQuarterMasters(Faction *pFac)
return i;
}

int Game::CountTacticians(Faction *pFac)
{
int i = 0;
forlist(&regions) {
ARegion *r = (ARegion *)elem;
forlist(&r->objects) {
Object *o = (Object *)elem;
forlist(&o->units) {
Unit *u = (Unit *)elem;
if(u->faction == pFac && u->GetSkill(S_TACTICS) == 5) i++;
}
}
}
return i;
}

int Game::CountApprentices(Faction *pFac)
{
int i = 0;
Expand Down Expand Up @@ -1752,6 +1792,17 @@ int Game::AllowedQuarterMasters(Faction *pFac)
return allowedQuartermasters[points];
}

int Game::AllowedTacticians(Faction *pFac)
{
int points = pFac->type[F_WAR];

if (points < 0) points = 0;
if (points > allowedTacticiansSize - 1)
points = allowedTacticiansSize - 1;

return allowedTacticians[points];
}

int Game::AllowedApprentices(Faction *pFac)
{
int points = pFac->type[F_MAGIC];
Expand Down
9 changes: 8 additions & 1 deletion game.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class OrdersCheck
void Error(const AString &error);
};

/// The main game class
/** Currently this doc is here to switch on the class so that
I can see what the modify.cpp docs look like.
*/
class Game
{
friend class Faction;
Expand Down Expand Up @@ -133,6 +137,7 @@ class Game
void CountAllMages();
void CountAllApprentices();
void CountAllQuarterMasters();
void CountAllTacticians();
void WriteReport();
// LLS - write order templates
void WriteTemplates();
Expand Down Expand Up @@ -371,6 +376,7 @@ class Game
int CountMages(Faction *);
int CountApprentices(Faction *);
int CountQuarterMasters(Faction *);
int CountTacticians(Faction *);
void FindDeadFactions();
void DeleteEmptyUnits();
void DeleteEmptyInRegion(ARegion *);
Expand All @@ -385,12 +391,13 @@ class Game
//
// Faction limit functions.
//
// The first 3 are game specific and can be found in extra.cpp. They
// The first 4 are game specific and can be found in extra.cpp. They
// may return -1 to indicate no limit.
//
int AllowedMages(Faction *pFac);
int AllowedApprentices(Faction *pFact);
int AllowedQuarterMasters(Faction *pFact);
int AllowedTacticians(Faction *pFact);
int AllowedTaxes(Faction *pFac);
int AllowedTrades(Faction *pFac);
int TaxCheck(ARegion *pReg, Faction *pFac);
Expand Down
5 changes: 5 additions & 0 deletions gamedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ extern int *allowedTrades;
extern int allowedTradesSize;
extern int *allowedQuartermasters;
extern int allowedQuartermastersSize;
extern int *allowedTacticians;
extern int allowedTacticiansSize;

extern int NUMBATTLEITEMS;
extern int NUMARMORS;
Expand Down Expand Up @@ -672,6 +674,9 @@ class GameDefs {
// How developed pre-existing towns are at the start of the game
// (100 = standard).
int TOWN_DEVELOPMENT;

// Whether you need to be a war faction to have tact-5 leaders
int TACTICS_NEEDS_WAR;
};

extern GameDefs *Globals;
Expand Down
18 changes: 15 additions & 3 deletions genrules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,12 @@ int Game::GenRules(const AString &rules, const AString &css,
"be changed at the beginning of each turn, so a faction can "
"change and adapt to the conditions around it. Faction Points "
"spent on War determine the number of regions in which factions "
"can obtain income by taxing or pillaging. Faction Points spent "
"can obtain income by taxing or pillaging";
if (Globals->TACTICS_NEEDS_WAR) {
temp += ", and also determines the number of level 5 tactics "
"leaders (tacticians) that a faction can train";
}
temp += ". Faction Points spent "
"on Trade determine the number of regions in which a faction "
"may conduct trade activity. Trade activity includes producing "
"goods, building ships and buildings, and buying trade items. ";
Expand All @@ -504,7 +509,11 @@ int Game::GenRules(const AString &rules, const AString &css,
f.Enclose(1, "table border=\"1\"");
f.Enclose(1, "tr");
f.TagText("th", "Faction Points");
f.TagText("th", "War (max tax regions)");
temp = "War (max tax regions";
if(Globals->TACTICS_NEEDS_WAR)
temp += "/tacticians";
temp += ")";
f.TagText("th", temp);
temp = "Trade (max trade regions";
if (qm_exist)
temp += "/quartermasters";
Expand All @@ -526,7 +535,10 @@ int Game::GenRules(const AString &rules, const AString &css,
f.PutStr(i);
f.Enclose(0, "td");
f.Enclose(1, "td align=\"center\" nowrap");
f.PutStr(AllowedTaxes(&fac));
temp = AllowedTaxes(&fac);
if (Globals->TACTICS_NEEDS_WAR)
temp+= AString("/") + AllowedTacticians(&fac);
f.PutStr(temp);
f.Enclose(0, "td");
f.Enclose(1, "td align=\"center\" nowrap");
temp = AllowedTrades(&fac);
Expand Down
Loading

0 comments on commit 2f6649f

Please sign in to comment.