Skip to content

Commit

Permalink
fix: vp-how-to-play-overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
trevelyan committed Jan 23, 2024
1 parent 76270a4 commit 4b2b509
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mods/his/his.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const GameTemplate = require('../../lib/templates/gametemplate');
const DebateOverlay = require('./lib/ui/overlays/debate');
const ChateauxOverlay = require('./lib/ui/overlays/chateaux');
const VPOverlay = require('./lib/ui/overlays/vp');
const NewWorldOverlay = require('./lib/ui/overlays/newworld');
const TreatiseOverlay = require('./lib/ui/overlays/treatise');
const FactionOverlay = require('./lib/ui/overlays/faction');
Expand Down Expand Up @@ -60,6 +61,7 @@ class HereIStand extends GameTemplate {
this.diet_of_worms_overlay = new DietOfWormsOverlay(this.app, this); // diet of worms
this.council_of_trent_overlay = new CouncilOfTrentOverlay(this.app, this); // council of trent
this.chateaux_overlay = new ChateauxOverlay(this.app, this); // build some fucking chateaux
this.vp_overlay = new VPOverlay(this.app, this); // end-of-turn points overlay
this.newworld_overlay = new NewWorldOverlay(this.app, this);
this.theses_overlay = new ThesesOverlay(this.app, this); // 95 theses
this.reformation_overlay = new ReformationOverlay(this.app, this); // reformations and counter-reformations
Expand Down Expand Up @@ -2754,6 +2756,16 @@ if (this.game.players.length > 2) {
game_mod.field_battle_overlay.renderFortification();
}
});
this.menu.addSubMenuOption("game-info", {
text : "VP",
id : "game-vp",
class : "game-vp",
callback : function(app, game_mod) {
game_mod.menu.hideSubMenus();
game_mod.vp_overlay.render();
}
});
/****
this.menu.addSubMenuOption("game-info", {
text : "New World",
id : "game-new-world",
Expand All @@ -2772,6 +2784,7 @@ if (this.game.players.length > 2) {
game_mod.chateaux_overlay.render("papacy");
}
});
****/
this.menu.addSubMenuOption("game-info", {
text : "Religion",
id : "game-religious-conflict",
Expand Down
149 changes: 149 additions & 0 deletions mods/his/lib/ui/overlays/vp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
const VPTemplate = require('./vp.template');
const SaitoOverlay = require("./../../../../../lib/saito/ui/saito-overlay/saito-overlay");

class VPOverlay {

constructor(app, mod){
this.app = app;
this.mod = mod;
this.visible = false;
this.overlay = new SaitoOverlay(app, mod);

this.help = [

`First Turn Scoring`

,

`The Early Game`

,

`The Mid-Game`

,

`The Late Game`

];

this.advice = [

`The Reformation starts and the Protestants begin converting spaces in Germany. The Papacy is well
ahead on the board, but as the Protestant religion spreads their their lead will narrow. Focus on
"publishing treatises" and holding "debates" to spread your ideas. Translating the New Testament
into German is also an excellent move.`
,

`Once the Protestants control 12 spaces the Schmalkaldic League can form if its card is played (if
unplayed, the league will form automatically at the end of the 4th round). At this point Protestant
spaces in Germany will become Protestant home spaces and the Protestants will gain 2 VP per
electorate they control. Convert those electorates now in preparation!`

,

`With the Schmalkaldic League in play, the Protestants must now battle the Hapsburgs (militarily)
as well as the Papacy (theologically). You may also spread religious conflict out of Germany and
across Europe. Conversion attempts will soon get more difficult.`

,

`Victory goes to whichever power is in the lead at the end of the 9th round, or whichever power
secures an 8 VP lead by end-of-turn scoring in any earlier round.`

];

}

pullHudOverOverlay() {
let overlay_zindex = parseInt(this.overlay.zIndex);
if (document.querySelector(".hud")) {
document.querySelector(".hud").style.zIndex = overlay_zindex+1;
this.mod.hud.zIndex = overlay_zindex+1;
}
}

pushHudUnderOverlay() {
let overlay_zindex = parseInt(this.overlay.zIndex);
if (document.querySelector(".hud")) {
document.querySelector(".hud").style.zIndex = overlay_zindex-2;
this.mod.hud.zIndex = overlay_zindex-2;
}
}

hide() {
this.visible = false;
this.overlay.hide();
}
render() {

if (this.mod.game.player === this.mod.returnPlayerCommandingFaction("papacy")) {

this.advice = [

`The Reformation starts and the Protestants begin converting spaces in Germany. The Papacy should
focus on containing the initial spread of Protestantism in Europe, or take advantage of its early
lead to expand its control of keys in Italy for the extra VP points.`

,

`Once the Protestants control 12 spaces the Schmalkaldic League can form if its card is played (if
unplayed, the league will form automatically at the end of the 4th round). The Papacy will find it
easier to slow the Protestant menace after that if the Protestants are not in control of all of the
electorates in Germany.`

,

`With the Schmalkaldic League in play, the Papacy and Hapsburgs may work together to contain the
Protestants both militarily as well as theologically. Religious conflict will spread across
Europe, but the Papacy will soon find counter-reformations easier to carry-out.`

,

`Victory goes to whichever power is in the lead at the end of the 9th round, or whichever power
secures an 8 VP lead by end-of-turn scoring in any earlier round.`

];

}


this.visible = true;
this.overlay.show(VPTemplate());

let vp = this.mod.calculateVictoryPoints();

for (let i in vp) {
let html = `
<div>
<div class="title">${this.mod.returnFactionName(vp[i].faction)}</div>
<div class="desc">${vp[i].vp_base} VP base + ${vp[i].vp_special} special VP + ${vp[i].vp_bonus} bonus VP</div>
<div class="vp">${vp[i].vp} VP</div>
</div>
`;
this.app.browser.addElementToSelector(html, '.vp-overlay .factions');
}

let advice_index = 1;

if (this.mod.game.state.round == 1) {
advice_index = 0;
}
if (this.mod.game.state.schmalkaldic_league == 1) {
advice_index = 2;
}
if (this.mod.game.state.round >= 5) {
advice_index = 3;
}

this.app.browser.addElementToSelector(this.advice[advice_index], '.vp-overlay .help');
this.app.browser.addElementToSelector(this.advice[advice_index], '.vp-overlay .advice');

this.pullHudOverOverlay();

}

}

module.exports = VPOverlay;

19 changes: 19 additions & 0 deletions mods/his/lib/ui/overlays/vp.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = () => {

let help = ``;
let advice = ``;

let html = `
<div class="vp-overlay" id="vp-overlay">
<div class="help">${help}</div>
<div class="factions"></div>
<div class="advice">${advice}</div>
</div>
`;
return html;

}




2 changes: 2 additions & 0 deletions mods/his/src/his-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const GameTemplate = require('../../lib/templates/gametemplate');
const DebateOverlay = require('./lib/ui/overlays/debate');
const ChateauxOverlay = require('./lib/ui/overlays/chateaux');
const VPOverlay = require('./lib/ui/overlays/vp');
const NewWorldOverlay = require('./lib/ui/overlays/newworld');
const TreatiseOverlay = require('./lib/ui/overlays/treatise');
const FactionOverlay = require('./lib/ui/overlays/faction');
Expand Down Expand Up @@ -60,6 +61,7 @@ class HereIStand extends GameTemplate {
this.diet_of_worms_overlay = new DietOfWormsOverlay(this.app, this); // diet of worms
this.council_of_trent_overlay = new CouncilOfTrentOverlay(this.app, this); // council of trent
this.chateaux_overlay = new ChateauxOverlay(this.app, this); // build some fucking chateaux
this.vp_overlay = new VPOverlay(this.app, this); // end-of-turn points overlay
this.newworld_overlay = new NewWorldOverlay(this.app, this);
this.theses_overlay = new ThesesOverlay(this.app, this); // 95 theses
this.reformation_overlay = new ReformationOverlay(this.app, this); // reformations and counter-reformations
Expand Down
11 changes: 11 additions & 0 deletions mods/his/src/his-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ if (this.game.players.length > 2) {
game_mod.field_battle_overlay.renderFortification();
}
});
this.menu.addSubMenuOption("game-info", {
text : "VP",
id : "game-vp",
class : "game-vp",
callback : function(app, game_mod) {
game_mod.menu.hideSubMenus();
game_mod.vp_overlay.render();
}
});
/****
this.menu.addSubMenuOption("game-info", {
text : "New World",
id : "game-new-world",
Expand All @@ -274,6 +284,7 @@ if (this.game.players.length > 2) {
game_mod.chateaux_overlay.render("papacy");
}
});
****/
this.menu.addSubMenuOption("game-info", {
text : "Religion",
id : "game-religious-conflict",
Expand Down
58 changes: 58 additions & 0 deletions mods/his/web/css/his-vp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

.vp-overlay {
background-image: url(/his/img/backgrounds/new_world.jpg);
background-size: cover;
max-height: 90vh;
max-width: 90vw;
width: 90vw;
height: auto;
min-height: 622px;
text-align: center;
}

.vp-overlay .help {
background: #0009;
width: 100%;
color: white;
margin-left: auto;
margin-right: auto;
font-size: 2.4rem;
padding: 0.75rem;
max-width: 100%;
padding: 2rem;
line-height: 3.4rem;
}

.vp-overlay .factions {
display: flex;
flex-direction: column;
margin-top: 5rem;
margin-bottom: 5rem;
width: 80%;
background-color: #0009;
margin-left: auto;
margin-right: auto;
color: white;
}

.vp-overlay .factions div {
width: 100%;
max-width: 100%;
display: flex;
flex-direction: row;
font-size: 2rem;
padding: 1rem;
}


.vp-overlay .factions div .title {

}
.vp-overlay .factions div .title {
font-size: 1.5rem;
text-align: left;
}
.vp-overlay .factions div .vp {
font-size: 4rem;
}

0 comments on commit 4b2b509

Please sign in to comment.