From 197e4ffc5df538d26d46143b878e5611b49e890b Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Fri, 10 Apr 2020 08:44:15 -0700 Subject: [PATCH] Birthdays! --- assets/game/acf/game.js | 2 +- src/components/farm/Board.jsx | 19 ++++++++++++------- src/components/farm/reducers.js | 2 +- src/server/farm.scm | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/assets/game/acf/game.js b/assets/game/acf/game.js index 82cde34..9987aac 100644 --- a/assets/game/acf/game.js +++ b/assets/game/acf/game.js @@ -44,7 +44,7 @@ export const spaceContent = 'License expired. Head back to the second week in January.', 'Frugivore swarm forces you to cover fruit. PAY $2000 if you own fruit.', `Finished plowing. Time for Apple pie. Draw ${itemCardShort}`, - 'Corn in without major solar flare. Yield is doubled this year.', + 'Birthday bonus! And corn in without major solar flare. Yield is doubled this year.', 'Winds continue. Work halts. PAY $500.', 'AI malfunction. PAY $1000.', 'Dust storms head south. COLLECT $500.', diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx index 04f422c..5fea180 100644 --- a/src/components/farm/Board.jsx +++ b/src/components/farm/Board.jsx @@ -22,6 +22,7 @@ import CowImg from './../../../assets/img/cow.svg' import HayImg from './../../../assets/img/hay.svg' import WheatImg from './../../../assets/img/wheat.svg' import TractorImg from './../../../assets/img/tractor-icon.svg' +import CakeImg from './../../../assets/img/cake.svg' import TractorFullImg from './../../../assets/img/tractor-with-spikes.svg' import HarvesterImg from './../../../assets/img/harvester.svg' import VolcanoImg from './../../../assets/img/volcano2.gif' @@ -50,17 +51,17 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept, function netWorth(player) { return ((player.assets.hay + player.assets.grain) * 2000) + - (player.assets.fruit * 5000) + - (player.assets.cows * 500) + - ((player.assets.harvester + player.assets.tractor) * 10000) + + (player.assets.fruit * 5000) + + (player.assets.cows * 500) + + ((player.assets.harvester + player.assets.tractor) * 10000) + player.displayCash - player.debt; } function assetsValue(player) { return ((player.assets.hay + player.assets.grain) * 2000) + - (player.assets.fruit * 5000) + - (player.assets.cows * 500) + - ((player.assets.harvester + player.assets.tractor) * 10000); + (player.assets.fruit * 5000) + + (player.assets.cows * 500) + + ((player.assets.harvester + player.assets.tractor) * 10000); } function getElementValue(id) { @@ -282,6 +283,10 @@ class PlayerResources extends React.Component { {player.assets.tractor} + {' '} + + {player.assets.birthday ? player.assets.birthday : 0} ); @@ -885,7 +890,7 @@ class Misc extends React.Component { Copyright Laymik with modifications by Thomas Hintz -
  • - Copyright Made - + Copyright Made -
  • Copyright rivercon - diff --git a/src/components/farm/reducers.js b/src/components/farm/reducers.js index 150ec51..4988994 100644 --- a/src/components/farm/reducers.js +++ b/src/components/farm/reducers.js @@ -88,7 +88,7 @@ const initialState = { debt: 5000, spaces, state: GAME_STATES.turnEnded, - assets: { hay: 10, grain: 10, fruit: 0, cows: 0, harvester: 0, tractor: 0 }, + assets: { hay: 10, grain: 10, fruit: 0, cows: 0, harvester: 0, tractor: 0, birthday: 0 }, color: '', name: '', ridges: { ridge1: 0, ridge2: 0, ridge3: 0, ridge4: 0 }, diff --git a/src/server/farm.scm b/src/server/farm.scm index 4977601..f724e30 100644 --- a/src/server/farm.scm +++ b/src/server/farm.scm @@ -106,7 +106,8 @@ (finished initform: #f accessor: player-finished) (assets initform: '((hay . 10) (grain . 10) (fruit . 0) (cows . 0) - (harvester . 0) (tractor . 0)) + (harvester . 0) (tractor . 0) + (birthday . 0)) accessor: player-assets) (ridges initform: '((ridge1 . 0) (ridge2 . 0) (ridge3 . 0) (ridge4 . 0)) @@ -1939,7 +1940,7 @@ (define (gains amount) (lambda (n) (+ n amount))) (define (player-crop-rule player crop) - (if (> (alist-ref crop (player-assets player)) 0) `(((tom ,crop))) '())) + (if (> (alist-ref crop (player-assets player) eqv? 0) 0) `(((tom ,crop))) '())) (define (aug4-action player) (when (not (already-harvested? 'wheat player)) @@ -1969,6 +1970,7 @@ ((apr2 add-rule ?p ,(make-player-year-rule 10 '((?p corn harvest-mult 2) (?p grain))))) ((apr2 player-action ?p ,(lambda (p) (safe-set! (player-corn-doubled p) #t)))) + ((apr2 money ?p ,(gains 5000)) (?p birthday)) ((apr3 money ?p ,(pays 500))) ((apr4 money ?p ,(pays 1000))) ((may1 money ?p ,(gains 500))) @@ -2045,7 +2047,8 @@ ,@(player-crop-rule player 'hay) ,@(player-crop-rule player 'grain) ,@(player-crop-rule player 'tractor) - ,@(player-crop-rule player 'harvester)) + ,@(player-crop-rule player 'harvester) + ,@(player-crop-rule player 'birthday)) `((,(list-ref *months* space) ?action tom ?value))))) (if a (begin (set! res (cons a res)) (loop (amb+))) @@ -2238,6 +2241,15 @@ (define (gp i) (list-ref (game-players (first-game)) i)) +(define (gn name) + (find (lambda (p) (equal? (player-name p) name)) + (game-players (first-game)))) + +(define (gnb name) + (let ((player (gn name))) + (safe-set! (player-assets player) + (alist-update 'birthday 1 (player-assets player))))) + (cond-expand (geiser '())