Skip to content

Commit

Permalink
GeM: PV history
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDr3ck committed Jan 20, 2024
1 parent 2d39f59 commit 0d0c17a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions GuildeMarchande/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ let overTrade = null;
let overExploration = false;
let overTreasure = false;
let overHelpButton = false;
let overCoins = false;
let overSpecialization = -1; // 0 or 1
let overSpecializedCard = -1; // 0, 1 or 2
let age = 1; // 1 to 4
let PV = 0;
let PVHistory = [];
let PVTreasure = 0;
let villageRegion = null;
let bestTradePV = 0;
Expand Down Expand Up @@ -1440,6 +1442,8 @@ function drawGoals() {
function addPV(str, value) {
uiManager.addLogger(`${str}: + ${value} PV`);
PV += value;
// add PV in last history item
PVHistory[PVHistory.length - 1].PV.push(`${str}: + ${value}`);
}

/**
Expand Down Expand Up @@ -1921,6 +1925,8 @@ function drawPlayableCase(cube, index) {
CARD.JOKER,
CARD.SEA,
`${CARD.SEA}|${CARD.GRASSLAND}`,
`${CARD.SEA}|${CARD.SAND}`,
`${CARD.SEA}|${CARD.MOUNTAIN}`,
];
const caseIndex = caseIndices.findIndex((cur) => cur === cube.type);
spritesheet.drawScaledSprite(
Expand Down Expand Up @@ -2103,6 +2109,10 @@ function drawGame() {
spritesheet.drawSprite(`${map}_rules`, 0, (windowWidth - 550) / 2, 50);
}

if (overCoins) {
drawAllPVHistory();
}

// draw animations
animations.forEach((animation) => animation.draw());
}
Expand Down Expand Up @@ -2379,6 +2389,8 @@ function newExplorationCard() {
// remove all cubes
removeCubes();
return;
} else {
PVHistory.push({ age: age, cardIndex: ageCards[0], PV: [] });
}
playState = CUBE_STATE;
if (ageCards.length > 0) {
Expand Down Expand Up @@ -2439,6 +2451,50 @@ function newExplorationCard() {
}
}

function drawPVHistory(ageHistory, rowPixel) {
if (ageHistory.length === 0) {
return;
}
ageHistory.forEach((history, index) => {
spritesheet.drawScaledSprite(
"exploration_cards",
history.cardIndex,
52 + 150 * index,
rowPixel,
0.45
);
history.PV.forEach((value, textIndex) => {
text(value, 55 + 10 + 150 * index, rowPixel + 25 + 15 + 20 * textIndex);
});
});
}
function drawPVTreasure() {
spritesheet.drawScaledSprite("tresor_cards", 4, 500, 26, 0.4);
text(`+ ${PVTreasure}`, 500 + 10, 25 + 20);
}
function drawAllPVHistory() {
noStroke();
fill(0);
textSize(15);
drawPVHistory(
PVHistory.filter((history) => history.age === 1),
135
);
drawPVHistory(
PVHistory.filter((history) => history.age === 2),
335
);
drawPVHistory(
PVHistory.filter((history) => history.age === 3),
535
);
drawPVHistory(
PVHistory.filter((history) => history.age === 4),
735
);
drawPVTreasure();
}

function addValidateButton() {
validateButton.enabled = false;
validateForceButton.enabled = true;
Expand Down Expand Up @@ -2751,6 +2807,7 @@ function mouseMoved() {
overCell = null;
overTrade = null;
overHelpButton = distance(1500, 40, mouseX, mouseY) < 25;
overCoins = distance(1382, 569, mouseX, mouseY) < 40;
if (playState === CUBE_STATE) {
board.forEach((column, x) =>
column.forEach((cell, y) => {
Expand Down Expand Up @@ -2971,6 +3028,7 @@ function initBoard(map = "avenia") {
board = [];
age = 1;
PV = 0;
PVHistory = [];
PVTreasure = 0;
blockGoalIndex = 0;
let dx = 179 - 46.5 * 2;
Expand Down

0 comments on commit 0d0c17a

Please sign in to comment.