summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-08-29 09:01:18 -0700
committerThomas Hintz <t@thintz.com>2020-08-29 09:01:18 -0700
commit1b9e94ba1fbee928ddbb47c63e368f7fb88fb5e4 (patch)
treeed21313e84eff27e63ba83492ecd44418ef2b7a6
parent191a6081b70e6c894a28c03659f6d3095f30a85e (diff)
downloadfarm-1b9e94ba1fbee928ddbb47c63e368f7fb88fb5e4.tar.gz
New stats and bug fixes.
-rw-r--r--Makefile3
-rw-r--r--src/components/farm/Board.jsx11
-rw-r--r--src/server/farm.scm21
-rw-r--r--src/style.scss2
-rw-r--r--webpack.common.js5
-rw-r--r--webpack.dev.js9
-rw-r--r--webpack.prod.js8
7 files changed, 45 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 0298d9e..9acd904 100644
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,9 @@ install:
interactive:
csi -include-path $(assets) -include-path src/server -s src/server/farm.scm
+interactiveserver:
+ cd dist ; csi -include-path $(assets) -include-path ../src/server -s farm.scm
+
src/server/farm: src/server/farm.scm src/server/db.scm
cd src/server/ && csc -include-path ../../$(assets) -O3 farm.scm
diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx
index a090e7b..33f3890 100644
--- a/src/components/farm/Board.jsx
+++ b/src/components/farm/Board.jsx
@@ -1506,10 +1506,10 @@ class Harvest extends React.Component {
view = (
<div>
<div className='game-card'>
- <div className={'flex ' + (currentExpense <= 0 ? 'red' : 'green')}>
+ <div className={'flex ' + (currentExpense < 0 ? 'red' : 'green')}>
<FontAwesomeIcon icon={faDollarSign} size='6x' />
<div>
- {currentExpense ? (
+ {typeof currentExpense === 'number' ? (
<p>
{isCurrentPlayer ? 'You' : this.props.game.currentPlayer}
{currentExpense <= 0 ? ' lost ' : ' gained '}
@@ -2037,6 +2037,7 @@ const GameOver = ({ id, alertHandled, contents, game, player}) => {
<p>Total: ${formatMoney(p.harvestTotal)} Expenses: ${formatMoney(Math.abs(p.operatingExpenses))}</p>
<p>Avg ${formatMoney(p.harvestAverage)} rolling {p.harvestRoll} for {p.numHarvests} harvests</p>
<p>Hay: ${formatMoney(p.hay)} Grain: ${formatMoney(p.grain)} Fruit: ${formatMoney(p.fruit)} Cows: ${formatMoney(p.cows)}</p>
+ <p>Tractor: ${formatMoney(p.tractor)} Harvester: ${formatMoney(p.harvester)}</p>
</div>))}
</div>
<div className={tabClass(gameOverTabs.investments)}>
@@ -2049,7 +2050,11 @@ const GameOver = ({ id, alertHandled, contents, game, player}) => {
<p>Hay: {(p.hay / ((pObj.assets.hay * 2000) || 0.001)).toFixed(2)} {' '}
Grain: {(p.grain / ((pObj.assets.grain * 2000) || 0.001)).toFixed(2)} {' '}
Fruit: {(p.fruit / ((pObj.assets.fruit * 5000) || 0.001)).toFixed(2)} {' '}
- Cows: {(p.cows / (((pObj.assets.cows * 500) + (playerRidgeValue(pObj, game.otherPlayers))) || 0.001)).toFixed(2)}
+ Cows: {(p.cows / ((((pObj.assets.cows + p.cowsLost) * 500) + (playerRidgeValue(pObj, game.otherPlayers))) || 0.001)).toFixed(2)}
+ </p>
+ <p>
+ Tractor: {Math.max(0, (p.tractor / ((pObj.assets.tractor * 10000) || 0.001))).toFixed(2)} {' '}
+ Harvester: {Math.max(0, (p.harvester / ((pObj.assets.harvester * 10000) || 0.001))).toFixed(2)}
</p>
</div>
);
diff --git a/src/server/farm.scm b/src/server/farm.scm
index f0d26c3..8a1439d 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -185,7 +185,14 @@
(hay . 0)
(grain . 0)
(fruit . 0)
- (cows . 0)))
+ (cows . 0)
+ (tractor . 0)
+ (harvester . 0)
+ (hay-expenses . 0)
+ (grain-expenses . 0)
+ (fruit-expenses . 0)
+ (cows-expenses . 0)
+ (cows-lost . 0)))
(alist-ref 'ai? args eqv? #f)
(alist-ref 'processing-turn args eqv? #f))))
@@ -568,7 +575,7 @@
;; (session-set! (sid) 'game *game*)
;; (set-startup-otbs (session-ref (sid) 'player) 2)
)
- (send-static-file "index.html")
+ (send-static-file "main.html")
;; (with-headers `((connection close)
;; (content-type text/html))
;; (lambda ()
@@ -577,7 +584,7 @@
)
(define (start-game)
- (send-static-file "index.html")
+ (send-static-file "main.html")
""
;; (with-output-to-string
;; (lambda ()
@@ -1038,6 +1045,9 @@
(grain . ,(alist-ref 'grain stats))
(fruit . ,(alist-ref 'fruit stats))
(cows . ,(alist-ref 'cows stats))
+ (cowsLost . ,(alist-ref 'cows-lost stats eqv? 0))
+ (tractor . ,(alist-ref 'tractor stats))
+ (harvester . ,(alist-ref 'harvester stats))
(harvestAverage . ,(exact->inexact
(round
(/ (fold + 0 (map (lambda (c) (alist-ref c stats))
@@ -2049,9 +2059,11 @@
(inexact->exact
(round (/ (exact->inexact amount) num-equipment))))))
(for-each (lambda (player)
+ ((make-player-stat equipment amount-per-player) player)
(safe-set! (player-cash player)
(+ (player-cash player) amount-per-player)))
(players-with equipment game)))))
+ ((make-player-stat equipment (- amount)) player)
(safe-set! (player-cash player) (- (player-cash player) amount))))
(define (make-player-gains amount)
@@ -2232,6 +2244,8 @@
(for-each (lambda (from-player)
(when (not (eq? player from-player))
(when (not (player-has-asset? 'harvester from-player))
+ ((make-player-stat equipment -2000) from-player)
+ ((make-player-stat equipment 2000) player)
(safe-set! (player-cash from-player)
(- (player-cash from-player) 2000))
(safe-set! (player-cash player)
@@ -2290,6 +2304,7 @@
(safe-set! (player-assets player)
(alist-update 'cows (- (alist-ref 'cows (player-assets player)) (- cows ridge-cows))
(player-assets player)))
+ ((make-player-stat 'cows-lost slaughtered-cows) player)
`(((?action . info)
(?value . ,(conc slaughtered-cows
" cows slaughtered on your farm.")))))
diff --git a/src/style.scss b/src/style.scss
index 6000835..8f9e297 100644
--- a/src/style.scss
+++ b/src/style.scss
@@ -305,7 +305,7 @@ $tab-margin: 0.3rem;
.player-black {
background-color: black; }
.player-none {
- background-color: #f2f2f2; }
+ background-color: #f2f2f2; } //
.tab .player {
height: 27px;
diff --git a/webpack.common.js b/webpack.common.js
index 1136e8e..a956aa1 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -48,11 +48,6 @@ module.exports = {
},
plugins: [
new CleanWebpackPlugin(),
- new HtmlWebpackPlugin({
- title: 'Alpha Centauri Farming',
- filename: 'index.html',
- meta: {viewport: 'width=device-width, initial-scale=1'},
- }),
new FaviconsWebpackPlugin('./assets/img/tractor.svg'),
new MiniCssExtractPlugin({
filename: './assets/[name].[hash].css',
diff --git a/webpack.dev.js b/webpack.dev.js
index 421829a..ae4cadb 100644
--- a/webpack.dev.js
+++ b/webpack.dev.js
@@ -19,7 +19,7 @@
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
-
+const HtmlWebpackPlugin = require('html-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
module.exports = function(env) {
@@ -43,7 +43,12 @@ module.exports = function(env) {
'node_modules']
},
plugins: [
- new ReactRefreshWebpackPlugin()
+ new ReactRefreshWebpackPlugin(),
+ new HtmlWebpackPlugin({
+ title: 'Alpha Centauri Farming',
+ filename: 'index.html',
+ meta: {viewport: 'width=device-width, initial-scale=1'},
+ }),
],
module: {
rules: [
diff --git a/webpack.prod.js b/webpack.prod.js
index f8c2d1d..efe3cc1 100644
--- a/webpack.prod.js
+++ b/webpack.prod.js
@@ -22,6 +22,7 @@ const path = require('path');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
+const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function(env) {
return merge(common, {
@@ -32,6 +33,13 @@ module.exports = function(env) {
path.resolve(__dirname, env.assets),
'node_modules']
},
+ plugins: [
+ new HtmlWebpackPlugin({
+ title: 'Alpha Centauri Farming',
+ filename: 'main.html',
+ meta: {viewport: 'width=device-width, initial-scale=1'},
+ }),
+ ],
optimization: {
minimize: true,
minimizer: [new OptimizeCssAssetsPlugin({}), new TerserPlugin()],