forked from retoor/devplacepy
feat: add steal mechanic to Code Farm with 60s protection window and half-coin reward
This commit is contained in:
@@ -50,7 +50,10 @@ export class GameFarm {
|
||||
try {
|
||||
const data = await Http.send(form.getAttribute("action"), params);
|
||||
this.render(data.farm);
|
||||
if (action === "harvest" || action === "water" || action === "prestige") {
|
||||
if (action === "steal" && window.app && window.app.toast) {
|
||||
window.app.toast.show(`You stole ${data.stole_coins}c!`, { type: "success" });
|
||||
}
|
||||
if (action === "harvest" || action === "water" || action === "steal" || action === "prestige") {
|
||||
this._loadLeaderboard();
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -188,6 +191,8 @@ export class GameFarm {
|
||||
body = `<span class="plot-icon plot-ready-icon" aria-hidden="true">${plot.crop_icon}</span><span class="plot-crop-name">${plot.crop_name}</span>`;
|
||||
if (farm.is_owner) {
|
||||
body += `<form method="post" action="/game/harvest" data-game-action="harvest"><input type="hidden" name="slot" value="${plot.slot}"><button type="submit" class="btn btn-sm btn-primary">Harvest +${plot.reward_coins}c</button></form>`;
|
||||
} else if (plot.can_steal) {
|
||||
body += `<form method="post" action="/game/farm/${farm.owner_username}/steal" data-game-action="steal"><input type="hidden" name="slot" value="${plot.slot}"><button type="submit" class="btn btn-sm btn-danger" data-confirm="Steal this ready build?">Steal +${plot.steal_coins}c</button></form>`;
|
||||
} else {
|
||||
body += `<span class="plot-ready-label">Ready</span>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user