From cae8b90c698a869b41f494978485ec5ca8180923 Mon Sep 17 00:00:00 2001 From: hexall90 <hexall90@gmail.com> Date: Tue, 19 Sep 2017 12:36:39 +0200 Subject: [PATCH] continuing on attackReport --- Security expansion documentation.txt | 13 + src/SecExp/SecExpBackwardCompatibility.tw | 26 +- src/SecExp/attackHandler.tw | 17 +- src/SecExp/attackOptions.tw | 12 +- src/SecExp/attackReport.tw | 499 +++++++++++++++------- src/SecExp/secInit.tw | 10 +- 6 files changed, 389 insertions(+), 188 deletions(-) create mode 100644 Security expansion documentation.txt diff --git a/Security expansion documentation.txt b/Security expansion documentation.txt new file mode 100644 index 00000000000..cd46b4e83f5 --- /dev/null +++ b/Security expansion documentation.txt @@ -0,0 +1,13 @@ + + +$maxTurns: +The maximum number of "turns" the battle is allowed to continue. In practice the number of loops attackHandler goes through to determine the victor. + +$battleResult: +-3 defeat (either our morale or hp reached 0 or below) +-2 partial defeat (the battle lasted more than $maxTurns and enemy morale was higher) +-1 surrender (the player chose to surrender) +0 failed bribery (not enough money or wrong enemy, eg. freedom figthers) +1 successful bribery (enemy bribed) +2 partial victory (the battle lasted more than $maxTurns and our morale was higher) +3 victory (either enemy morale or hp reached 0 or below) \ No newline at end of file diff --git a/src/SecExp/SecExpBackwardCompatibility.tw b/src/SecExp/SecExpBackwardCompatibility.tw index 598f27683f1..640eb59b101 100644 --- a/src/SecExp/SecExpBackwardCompatibility.tw +++ b/src/SecExp/SecExpBackwardCompatibility.tw @@ -22,8 +22,14 @@ <<if ndef $lastAttackWeeks>> <<set $lastAttackWeeks = 0>> <</if>> -<<if ndef $hasFought>> - <<set $hasFought = 0>> +<<if ndef $hasFoughtOnce>> + <<set $hasFoughtOnce = 0>> +<</if>> +<<if ndef $PCvictoryStreak>> +<<set $PCvictoryStreak = 0>> +<</if>> +<<if ndef $PClossStreak>> +<<set $PClossStreak = 0>> <</if>> /* upgrades */ @@ -74,20 +80,8 @@ <<if ndef $maxTurns>> <<set $maxTurns = 10>> <</if>> -<<if ndef $PCwon>> - <<set $PCwon = 0>> -<</if>> -<<if ndef $EnemyWon>> - <<set $EnemyWon = 0>> -<</if>> -<<if ndef $PCpartialWon>> - <<set $PCpartialWon = 0>> -<</if>> -<<if ndef $enemyPartialWon>> - <<set $enemyPartialWon = 0>> -<</if>> -<<if ndef $PCsurrenders>> - <<set $PCsurrenders = 0>> +<<if ndef $battleResult>> + <<set $battleResult = 4>> /* sets $battleResult value outside accepted range (-3,3) to avoid evaluation problems */ <</if>> <<if ndef $losses>> <<set $losses = 0>> diff --git a/src/SecExp/attackHandler.tw b/src/SecExp/attackHandler.tw index 2c3adef5fb4..a3c9c1edea3 100644 --- a/src/SecExp/attackHandler.tw +++ b/src/SecExp/attackHandler.tw @@ -1,5 +1,6 @@ :: attackHandler [nobr] +<<if $battleResult != 1 || $battleResult != -1>> /* if the player did not select bribe or surrender */ /*Init*/ <<set _turn = 0>> <<set _attack = 0>> @@ -488,7 +489,7 @@ Debug: <br> Debug: remaining enemyMorale: _enemyMorale <<if _enemyHp <= 0 || _enemyMorale <= 0>> - <<set $PCwon = 1>> + <<set $battleResult = 3>> <<set $battleTurns = _i>> <<break>> <</if>> @@ -505,19 +506,25 @@ Debug: <br> Debug: remaining morale: _morale <<if _hp <= 0 || _morale <= 0>> - <<set $EnemyWon = 1>> + <<set $battleResult = -3>> <<set $battleTurns = _i>> <<break>> <</if>> <</for>> -<<if $PCwon != 1 && $EnemyWon != 1>> +<<if $battleResult != 3 && $battleResult != -3>> <<if _morale > _enemyMorale>> - <<set $PCpartialWon = 1>> + <<set $battleResult = 2>> <<elseif _morale < _enemyMorale>> - <<set $enemyPartialWon = 1>> + <<set $battleResult = -2>> <</if>> <</if>> +<<else>> /* bribe/surrender code */ + Debug: bribe/surrender +<</if>> /* closes bribe/surrender check */ +<<if $battleResult > 3 || $battleResult < -3>> + Error: failed to determine battle result +<</if>> <br><br> <<link "proceed">> diff --git a/src/SecExp/attackOptions.tw b/src/SecExp/attackOptions.tw index 5cfe8c7158a..8349da6e6c9 100644 --- a/src/SecExp/attackOptions.tw +++ b/src/SecExp/attackOptions.tw @@ -92,7 +92,7 @@ The ominous message dominates the screens of your office, <<print $assistantName <</if>> <</if>> - <<if $hasFought != 1>> + <<if $hasFoughtOnce != 1>> <br> This is your first battle as an arcology owner, <<print $assistantName>> suggests reviewing the meaning of all the data laying in front of you: [[Battle statistics and mechanics|secTutorial]] <</if>> @@ -404,6 +404,7 @@ Offensive Tactics <br> <<if $deployedUnits > 0>> <<link "Send your orders">> + <<set $battleResult = 4>> /* sets $battleResult value outside accepted range to avoid evaluation problems */ <<goto "attackHandler">> <</link>> <<else>> @@ -411,6 +412,11 @@ Offensive Tactics <</if>> <br> <<link "Surrender">> - <<set $PCsurrenders = 1>> - <<goto "attackReport">> + <<set $battleResult = -1>> + <<goto "attackHandler">> +<</link>> +<br> +<<link "Attempt to bribe">> + <<set $battleResult = 1>> + <<goto "attackHandler">> <</link>> \ No newline at end of file diff --git a/src/SecExp/attackReport.tw b/src/SecExp/attackReport.tw index ef16385760c..8f824e1b006 100644 --- a/src/SecExp/attackReport.tw +++ b/src/SecExp/attackReport.tw @@ -1,188 +1,371 @@ :: attackReport [nobr] /* result */ -<<if $PCwon == 1>> +<<if $battleResult == 3>> <strong>Victory!</strong> -<<elseif $EnemyWon == 1>> + <<set $PClossStreak = 0>> + <<set $PCvictoryStreak += 1>> +<<elseif $battleResult == -3>> <strong>Defeat!</strong> -<<elseif $PCpartialWon == 1>> + <<set $PClossStreak += 1>> + <<set $PCvictoryStreak = 0>> +<<elseif $battleResult == 2>> <strong>Partial victory!</strong> -<<elseif $enemyPartialWon == 1>> +<<elseif $battleResult == -2>> <strong>Partial defeat!</strong> -<<elseif $PCsurrenders == 1>> +<<elseif $battleResult == -1>> <strong>We surrendered</strong> +<<elseif $battleResult == 0>> + <strong>Failed bribery!</strong> +<<elseif $battleResult == 1>> + <strong>Successful bribery!</strong> <</if>> <hr> <<set $enemyLosses = Math.round($enemyLosses)>> <<set $losses = Math.round($losses)>> -<<if $PCsurrenders != 1>> - <<if $attackType == "raiders">> - Today, the $day of $month, $year, our arcology was attacked by a band of wild raiders, $attackTroops men strong. Our defense forces clashed with them - <<if $battleTerrain == "urban">> - in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, +<<if $attackType == "raiders">> + Today, the $day of $month, $year, our arcology was attacked by a band of wild raiders, $attackTroops men strong. Our defense forces clashed with them + <<if $battleTerrain == "urban">> + in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, <<elseif $battleTerrain == "rural">> - in the rural land surrounding the free city, - <<elseif $battleTerrain == "hills">> - on the hills around the free city, - <<elseif $battleTerrain == "coast">> - along the coast just outside the free city, + in the rural land surrounding the free city, + <<elseif $battleTerrain == "hills">> + on the hills around the free city, + <<elseif $battleTerrain == "coast">> + along the coast just outside the free city, <<elseif $battleterrain == "outskirts">> - just against the walls of the arcology, - <<elseif $battleTerrain == "mountains">> - in the mountains overlooking the arcology, - <<elseif $battleTerrain == "wasteland">> - in the wastelands outside the free city territory, - <</if>> - inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. - <<if $PCwon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men easily stopped the disorganized horde futile attempt at raiding your arcology. - <<elseif $battleTurns <= 7>> - The fight was hard, but in the end our men stopped the disorganized horde attempt at raiding your arcology. - <<else>> - The fight was long and hard, but our men managed to stop the horde raiding party. - <</if>> - <<elseif $EnemyWon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men were easily crushed by the barbaric horde of raiders. - <<elseif $battleTurns <= 7>> - The fight was hard and in the end the bandits proved too much to handle for our men. - <<else>> - The fight was long and hard, but despite their bravery the horde proved too much for our men. - <</if>> - <<elseif $PCpartialWon == 1>> - The fight was long and hard, but in the end our men managed to repel the raiders, though without making any significant gain. - <<elseif $enemyPartialWon == 1>> - The fight was long and hard. Our men in the end had to yield to the horde raiders, which was fortunately unable to capitalized on their victory. + just against the walls of the arcology, + <<elseif $battleTerrain == "mountains">> + in the mountains overlooking the arcology, + <<elseif $battleTerrain == "wasteland">> + in the wastelands outside the free city territory, + <</if>> + inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. + <<if $battleResult == 3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men easily stopped the disorganized horde futile attempt at raiding your arcology + <<elseif $battleTurns <= 7>> + The fight was hard, but in the end our men stopped the disorganized horde attempt at raiding your arcology + <<else>> + The fight was long and hard, but our men managed to stop the horde raiding party <</if>> - <<elseif $attackType == "free city">> - Today, the $day of $month, $year, our arcology was attacked by a contingent of mercenaries hired by a competing free city, $attackTroops men strong. Our defense forces clashed with them - <<if $battleTerrain == "urban">> - in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, - <<elseif $battleTerrain == "rural">> - in the rural land surrounding the free city, - <<elseif $battleTerrain == "hills">> - on the hills around the free city, - <<elseif $battleTerrain == "coast">> - along the coast just outside the free city, - <<elseif $battleterrain == "outskirts">> - just against the walls of the arcology, - <<elseif $battleTerrain == "mountains">> - in the mountains overlooking the arcology, - <<elseif $battleTerrain == "wasteland">> - in the wastelands outside the free city territory, - <</if>> - inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. - <<if $PCwon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men easily stopped the mercenaries dead in their tracks. - <<elseif $battleTurns <= 7>> - The fight was hard, but in the end our men stopped the slavers attempt at weakening your arcology. - <<else>> - The fight was long and hard, but our men managed to stop the free city mercenaries. - <</if>> - <<elseif $EnemyWon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men were easily crushed by the consumed mercenary veterans sent against us. - <<elseif $battleTurns <= 7>> - The fight was hard and in the end the slavers proved too much to handle for our men. - <<else>> - The fight was long and hard, but despite their bravery the mercenary slavers proved too much for our men. - <</if>> - <<elseif $PCpartialWon == 1>> - The fight was long and hard, but in the end our men managed to repel the mercenaries, though without making any significant gain. - <<elseif $enemyPartialWon == 1>> - The fight was long and hard. Our men in the end had to yield to the slavers, which were fortunately unable to capitalized on their victory. + <<if $PCvictoryStreak >= 2>> + , adding another victory to the growing list of our military's successes. + <<elseif $PClossStreak >= 2>> + , finally putting an end to a series of unfortunate defeats. + <<else>> + . <</if>> - <<elseif $attackType == "freedom fighters">> - Today, the $day of $month, $year, our arcology was attacked by a group of freedom fighters bent on the destruction of the institution of slavery, $attackTroops men strong. Our defense forces clashed with them - <<if $battleTerrain == "urban">> - in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, - <<elseif $battleTerrain == "rural">> - in the rural land surrounding the free city, - <<elseif $battleTerrain == "hills">> - on the hills around the free city, - <<elseif $battleTerrain == "coast">> - along the coast just outside the free city, - <<elseif $battleterrain == "outskirts">> - just against the walls of the arcology, - <<elseif $battleTerrain == "mountains">> - in the mountains overlooking the arcology, - <<elseif $battleTerrain == "wasteland">> - in the wastelands outside the free city territory, - <</if>> - inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. - <<if $PCwon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men easily stopped the freedom fighters dead in their tracks. - <<elseif $battleTurns <= 7>> - The fight was hard, but in the end our men stopped the fighters attempt at freeing our slaves. - <<else>> - The fight was long and hard, but our men managed to stop the freedom figthers. - <</if>> - <<elseif $EnemyWon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men were easily crushed by the fanatical fury of the freedom figthers. - <<elseif $battleTurns <= 7>> - The fight was hard and in the end the freedom figthers proved too much to handle for our men. - <<else>> - The fight was long and hard, but despite their bravery the freedom figthers fury proved too much for our men. - <</if>> - <<elseif $PCpartialWon == 1>> + <<elseif $battleResult == -3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men were easily crushed by the barbaric horde of raiders + <<elseif $battleTurns <= 7>> + The fight was hard and in the end the bandits proved too much to handle for our men + <<else>> + The fight was long and hard, but despite their bravery the horde proved too much for our men + <</if>> + <<if $PCvictoryStreak >= 2>> + , so interrupting a long series of military successes. + <<elseif $PClossStreak >= 2>> + , confirming the long list of recent failures our armed forces collected. + <<else>> + . + <</if>> + <<elseif $battleResult == 2>> + The fight was long and hard, but in the end our men managed to repel the raiders, though without making any significant gain. + <<elseif $battleResult == -2>> + The fight was long and hard. Our men in the end had to yield to the horde raiders, which was fortunately unable to capitalized on their victory. + <<elseif $battleResult == -1>> + <<elseif $battleResult == 0>> + <<elseif 4battleResult == 1>> + <</if>> +<<elseif $attackType == "free city">> + Today, the $day of $month, $year, our arcology was attacked by a contingent of mercenaries hired by a competing free city, $attackTroops men strong. Our defense forces clashed with them + <<if $battleTerrain == "urban">> + in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, + <<elseif $battleTerrain == "rural">> + in the rural land surrounding the free city, + <<elseif $battleTerrain == "hills">> + on the hills around the free city, + <<elseif $battleTerrain == "coast">> + along the coast just outside the free city, + <<elseif $battleterrain == "outskirts">> + just against the walls of the arcology, + <<elseif $battleTerrain == "mountains">> + in the mountains overlooking the arcology, + <<elseif $battleTerrain == "wasteland">> + in the wastelands outside the free city territory, + <</if>> + inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. + <<if $battleResult == 3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men easily stopped the mercenaries dead in their tracks + <<elseif $battleTurns <= 7>> + The fight was hard, but in the end our men stopped the slavers attempt at weakening your arcology + <<else>> + The fight was long and hard, but our men managed to stop the free city mercenaries + <</if>> + <<if $PCvictoryStreak >= 2>> + , adding another victory to the growing list of our military's successes. + <<elseif $PClossStreak >= 2>> + , finally putting an end to a series of unfortunate defeats. + <<else>> + . + <</if>> + <<elseif $battleResult == -3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men were easily crushed by the consumed mercenary veterans sent against us + <<elseif $battleTurns <= 7>> + The fight was hard and in the end the slavers proved too much to handle for our men + <<else>> + The fight was long and hard, but despite their bravery the mercenary slavers proved too much for our men + <</if>> + <<if $PCvictoryStreak >= 2>> + , so interrupting a long series of military successes. + <<elseif $PClossStreak >= 2>> + , confirming the long list of recent failures our armed forces collected. + <<else>> + . + <</if>> + <<elseif $battleResult == 2>> + The fight was long and hard, but in the end our men managed to repel the mercenaries, though without making any significant gain. + <<elseif $battleResult == -2>> + The fight was long and hard. Our men in the end had to yield to the slavers, which were fortunately unable to capitalized on their victory. + <<elseif $battleResult == -1>> + <<elseif $battleResult == 0>> + <<elseif 4battleResult == 1>> + <</if>> +<<elseif $attackType == "freedom fighters">> + Today, the $day of $month, $year, our arcology was attacked by a group of freedom fighters bent on the destruction of the institution of slavery, $attackTroops men strong. Our defense forces clashed with them + <<if $battleTerrain == "urban">> + in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, + <<elseif $battleTerrain == "rural">> + in the rural land surrounding the free city, + <<elseif $battleTerrain == "hills">> + on the hills around the free city, + <<elseif $battleTerrain == "coast">> + along the coast just outside the free city, + <<elseif $battleterrain == "outskirts">> + just against the walls of the arcology, + <<elseif $battleTerrain == "mountains">> + in the mountains overlooking the arcology, + <<elseif $battleTerrain == "wasteland">> + in the wastelands outside the free city territory, + <</if>> + inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. + <<if $battleResult == 3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men easily stopped the freedom fighters dead in their tracks + <<elseif $battleTurns <= 7>> + The fight was hard, but in the end our men stopped the fighters attack + <<else>> + The fight was long and hard, but our men managed to stop the freedom figthers + <</if>> + <<if $PCvictoryStreak >= 2>> + , adding another victory to the growing list of our military's successes. + <<elseif $PClossStreak >= 2>> + , finally putting an end to a series of unfortunate defeats. + <<else>> + . + <</if>> + <<elseif $battleResult == -3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men were easily crushed by the fanatical fury of the freedom figthers + <<elseif $battleTurns <= 7>> + The fight was hard and in the end the freedom figthers proved too much to handle for our men + <<else>> + The fight was long and hard, but despite their bravery the freedom figthers fury proved too much for our men + <</if>> + <<if $PCvictoryStreak >= 2>> + , so interrupting a long series of military successes. + <<elseif $PClossStreak >= 2>> + , confirming the long list of recent failures our armed forces collected. + <<else>> + . + <</if>> + <<elseif $battleResult == 2>> The fight was long and hard, but in the end our men managed to repel the freedom fighters, though without making any significant gain. - <<elseif $enemyPartialWon == 1>> - The fight was long and hard. Our men in the end had to yield to the freedom figthers, which were fortunately unable to capitalized on their victory. + <<elseif $battleResult == -2>> + The fight was long and hard. Our men in the end had to yield to the freedom figthers, which were fortunately unable to capitalized on their victory. + <<elseif $battleResult == -1>> + <<elseif $battleResult == 0>> + <<elseif 4battleResult == 1>> + <</if>> +<<elseif $attackType == "old world">> + Today, the $day of $month, $year, our arcology was attacked by an old world nation, boasting a misplaced sense of superiority, $attackTroops men strong. Our defense forces clashed with them + <<if $battleTerrain == "urban">> + in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, + <<elseif $battleTerrain == "rural">> + in the rural land surrounding the free city, + <<elseif $battleTerrain == "hills">> + on the hills around the free city, + <<elseif $battleTerrain == "coast">> + along the coast just outside the free city, + <<elseif $battleterrain == "outskirts">> + just against the walls of the arcology, + <<elseif $battleTerrain == "mountains">> + in the mountains overlooking the arcology, + <<elseif $battleTerrain == "wasteland">> + in the wastelands outside the free city territory, + <</if>> + inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. + <<if $battleResult == 3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men easily stopped the old world soldiers dead in their tracks + <<elseif $battleTurns <= 7>> + The fight was hard, but in the end our men stopped the soldiers of the old world + <<else>> + The fight was long and hard, but our men managed to stop the old world soldiers <</if>> - <<elseif $attackType == "old world">> - Today, the $day of $month, $year, our arcology was attacked by an old world nation, boasting a misplaced sense of superiority, $attackTroops men strong. Our defense forces clashed with them - <<if $battleTerrain == "urban">> - in the streets of <<if $terrain == "urban">>the old world city surrounding the arcology<<else>>of the free city<</if>>, - <<elseif $battleTerrain == "rural">> - in the rural land surrounding the free city, - <<elseif $battleTerrain == "hills">> - on the hills around the free city, - <<elseif $battleTerrain == "coast">> - along the coast just outside the free city, - <<elseif $battleterrain == "outskirts">> - just against the walls of the arcology, - <<elseif $battleTerrain == "mountains">> - in the mountains overlooking the arcology, - <<elseif $battleTerrain == "wasteland">> - in the wastelands outside the free city territory, - <</if>> - inflicting $enemyLosses casualties, while sustaining $losses casualties themselves. - <<if $PCwon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men easily stopped the old world soldiers dead in their tracks. - <<elseif $battleTurns <= 7>> - The fight was hard, but in the end our men stopped the soldiers of the old world. - <<else>> - The fight was long and hard, but our men managed to stop the old world soldiers. - <</if>> - <<elseif $EnemyWon == 1>> - <<if $battleTurns <= 5>> - The fight was quick and one sided, our men were easily crushed by the discipline of the old world armies. - <<elseif $battleTurns <= 7>> - The fight was hard and in the end the old world proved too much to handle for our men. - <<else>> - The fight was long and hard, but despite their bravery the determination of the old world troops proved too much for our men. - <</if>> - <<elseif $PCpartialWon == 1>> - The fight was long and hard, but in the end our men managed to repel the old world soldiers, though without making any significant gain. - <<elseif $enemyPartialWon == 1>> - The fight was long and hard. Our men in the end had to yield to the old world soldiers, which were fortunately unable to capitalized on their victory. + <<if $PCvictoryStreak >= 2>> + , adding another victory to the growing list of our military's successes. + <<elseif $PClossStreak >= 2>> + , finally putting an end to a series of unfortunate defeats. + <<else>> + . + <</if>> + <<elseif $battleResult == -3>> + <<if $battleTurns <= 5>> + The fight was quick and one sided, our men were easily crushed by the discipline of the old world armies + <<elseif $battleTurns <= 7>> + The fight was hard and in the end the old world proved too much to handle for our men + <<else>> + The fight was long and hard, but despite their bravery the determination of the old world troops proved too much for our men <</if>> + <<if $PCvictoryStreak >= 2>> + , so interrupting a long series of military successes. + <<elseif $PClossStreak >= 2>> + , confirming the long list of recent failures our armed forces collected. + <<else>> + . + <</if>> + <<elseif $battleResult == 2>> + The fight was long and hard, but in the end our men managed to repel the old world soldiers, though without making any significant gain. + <<elseif $battleResult == -2>> + The fight was long and hard. Our men in the end had to yield to the old world soldiers, which were fortunately unable to capitalized on their victory. + <<elseif $battleResult == -1>> + <<elseif $battleResult == 0>> + <<elseif 4battleResult == 1>> <</if>> -<<else>> - Rather than waste lives, we chose not to resist, hoping for mercy. <</if>> - +<br> /* calculates effects on the city */ +<<if $battleResult == 3>> + Thanks to your victory, your @@.green;reputation@@ and @@.gray;authority@@ increased. You were also able to capture + <<if $attackType == "raiders">> + <<set $rep += 800>> + <<set $authority += 800>> + <<elseif $attackType == "free city">> + <<set $rep += 1200>> + <<set $authority += 1200>> + <<elseif $attackType == "freedom fighters">> + <<set $rep += 1500>> + <<set $authority += 1500>> + <<elseif $attackType == "old world">> + <<set $rep += 1200>> + <<set $authority += 1200>> + <</if>> + <<if $attackTroops - $enemyLosses <= 50>> + a small amount of attackers, + <<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>> + <<elseif $attackTroops - $enemyLosses <= 100>> + an healthy group of attackers, + <<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>> + <<elseif $attackTroops - $enemyLosses <= 150>> + a big group of attackers, + <<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>> + <<elseif $attackTroops - $enemyLosses <= 200>> + a huge group of attackers, + <<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>> + <<elseif $attackTroops - $enemyLosses > 200>> + a great amount of attackers, + <<set _captives = ($attackTroops - $enemyLosses) * 0.1 * random(1,3)>> + <</if>> + and some of their equipment, which once sold produced + <<if attackEquip == 0>> + @@.yellowgreen;a small amount of cash.@@ + <<set $cash += 1000>> + <<elseif $attackEquip == 1>> + @@.yellowgreen;a moderate amount of cash.@@ + <<set $cash += 5000>> + <<elseif $attackEquip == 2>> + @@.yellowgreen;a good amount of cash.@@ + <<set $cash += 10000>> + <<elseif $attackEquip == 3>> + @@.yellowgreen;a great amount of cash.@@ + <<set $cash += 15000>> + <<elseif $attackEquip == 4>> + @@.yellowgreen;wealth worthy of the mightiest warlord.@@ + <<set $cash += 20000>> + <</if>> + @@.red;Damage to the city was virtually non-existent@@, costing only pocket cash to bring the structure back to normal. The inhabitants as well reported little to no injuries, because of this the prosperity of the arcology did not suffer. + <<set $cash -= 1000>> + <<if $PCvictoryStreak >= 3>> + It seems your victories over the constant threats directed your way is having @@.green;a positive effect on the prosperity of the arcology@@, due to the security your leadership affords. + <<set $arcologies[0].prosperity += 5>> + <</if>> +<<elseif $battleResult == -3>> + Due to your defeat, your your @@.red;reputation@@ and @@.red;authority@@ decreased. Obviously your troops were not able to capture anyone or anything. + <<if $attackType == "raiders">> + <<set $rep -= 400>> + <<set $authority -= 400>> + <<elseif $attackType == "free city">> + <<set $rep -= 600>> + <<set $authority -= 600>> + <<elseif $attackType == "freedom fighters">> + <<set $rep -= 750>> + <<set $authority -= 750>> + <<elseif $attackType == "old world">> + <<set $rep -= 600>> + <<set $authority -= 600>> + <</if>> + In the raiding following the battle @@.red;the arcology sustained heavy damage@@, which will cost quite the amount of cash to fix. Reports of @@.red;citizens or slaves killed or missing@@ flood your office for a few days following the defeat. + <<set $cash -= 5000>> + <<if $week <= 30>> + <<set $ACitizens -= random(100)>> + <<set $ASlaves -= random(150)>> + <<set $arcologies[0].prosperity -= random(5)>> + <<elseif $week <= 60>> + <<set $ACitizens -= random(120)>> + <<set $ASlaves -= random(170)>> + <<set $arcologies[0].prosperity -= random(10)>> + <<elseif $week <= 90>> + <<set $ACitizens -= random(140)>> + <<set $ASlaves -= random(190)>> + <<set $arcologies[0].prosperity -= random(15)>> + <<elseif $week <= 120>> + <<set $ACitizens -= random(160)>> + <<set $ASlaves -= random(210)>> + <<set $arcologies[0].prosperity -= random(20)>> + <<else>> + <<set $ACitizens -= random(180)>> + <<set $ASlaves -= random(230)>> + <<set $arcologies[0].prosperity -= random(25)>> + <</if>> + <<if $PClossStreak >= 3>> + This only confirms the fears of many, @@.red;your arcology is not safe@@ and it is clear their business will be better somewhere else. + <<set $arcologies[0].prosperity += 5>> + <</if>> +<<elseif $battleResult == 2>> + <strong>Partial victory!</strong> +<<elseif $battleResult == -2>> + <strong>Partial defeat!</strong> +<<elseif $battleResult == -1>> + <strong>We surrendered</strong> +<<elseif $battleResult == 0>> + <strong>We surrendered</strong> +<<elseif $battleResult == 1>> + <strong>We surrendered</strong> +<</if>> + + + <<if $losses > 0>> <<set _loss = Math.trunc($losses / $deployedUnits)>> <<if $deployingBots == 1>> <<set $secBots.troops -= _loss>> + <</if>> <<if $deployingMilitia == 1>> <<set _mL = $militiaUnits.length>> <<for _i = 0; _i < _mL; _i++>> diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw index 95931173685..df289e1a50d 100644 --- a/src/SecExp/secInit.tw +++ b/src/SecExp/secInit.tw @@ -8,7 +8,9 @@ <<set $attackType = "none">> <<set $attackThisWeek = 0>> <<set $lastAttackWeeks = 0>> -<<set $hasFought = 0>> +<<set $hasFoughtOnce = 0>> +<<set $PCvictoryStreak = 0>> +<<set $PClossStreak = 0>> /* armed forces stats */ <<set $militiaCreated = 0>> @@ -38,11 +40,7 @@ <<set $deployingMercs = 0>> <<set $battleTerrain = "none">> <<set $maxTurns = 10>> -<<set $PCwon = 0>> -<<set $EnemyWon = 0>> -<<set $PCpartialWon = 0>> -<<set $enemyPartialWon = 0>> -<<set $PCsurrenders = 0>> +<<set $battleResult = 4>> /* sets $battleResult value outside accepted range (-3,3) to avoid evaluation problems */ <<set $losses = 0>> <<set $enemyLosses = 0>> <<set $battleTurns = 0>> -- GitLab