Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Andreas Nedbal
FarmingGame-web
Commits
d717f845
Commit
d717f845
authored
May 17, 2014
by
Jyrki
🐾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added wheatTimer
parent
113958b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
14 deletions
+62
-14
coffee/main.coffee
coffee/main.coffee
+34
-11
js/main.js
js/main.js
+28
-3
No files found.
coffee/main.coffee
View file @
d717f845
...
...
@@ -17,7 +17,7 @@ initItem = (defaultCount, consumable) ->
# items
window
.
gameVars
=
{
cattleGrid
s
:
initItem
1
,
false
cattleGrid
:
initItem
1
,
false
fields
:
initItem
1
,
false
gold
:
200
people
:
{
...
...
@@ -46,19 +46,29 @@ window.gameVars = {
# update all the counters and stop everything if the game was lost
updateCounters
=
->
# left panel
$
(
'span#valuables-gold'
).
html
window
.
gameVars
.
gold
$
(
'span#goods-wheat'
).
html
window
.
gameVars
.
wheat
.
count
$
(
'span#valuables-gold'
).
html
window
.
gameVars
.
gold
$
(
'span#goods-wheat'
).
html
window
.
gameVars
.
wheat
.
count
$
(
'span#goods-livestock'
).
html
window
.
gameVars
.
liveStock
.
count
$
(
'span#people-home'
).
html
window
.
gameVars
.
people
.
home
$
(
'span#people-war'
).
html
window
.
gameVars
.
people
.
war
$
(
'span#people-shelter'
).
html
window
.
gameVars
.
people
.
shelter
$
(
'span#people-all'
).
html
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
war
+
window
.
gameVars
.
people
.
shelter
$
(
'span#builds-fields'
).
html
window
.
gameVars
.
fields
.
count
$
(
'span#builds-cattle'
).
html
window
.
gameVars
.
cattleGrid
s
.
count
$
(
'span#people-home'
).
html
window
.
gameVars
.
people
.
home
$
(
'span#people-war'
).
html
window
.
gameVars
.
people
.
war
$
(
'span#people-shelter'
).
html
window
.
gameVars
.
people
.
shelter
$
(
'span#people-all'
).
html
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
war
+
window
.
gameVars
.
people
.
shelter
$
(
'span#builds-fields'
).
html
window
.
gameVars
.
fields
.
count
$
(
'span#builds-cattle'
).
html
window
.
gameVars
.
cattleGrid
.
count
# statistics
$
(
'td#stats-wheat-produced'
).
html
window
.
gameVars
.
wheat
.
produced
$
(
'td#stats-wheat-consumed'
).
html
window
.
gameVars
.
wheat
.
consumed
$
(
'td#stats-wheat-produced'
).
html
window
.
gameVars
.
wheat
.
produced
$
(
'td#stats-wheat-consumed'
).
html
window
.
gameVars
.
wheat
.
consumed
$
(
'td#stats-wheat-bought'
).
html
window
.
gameVars
.
wheat
.
bought
$
(
'td#stats-wheat-sold'
).
html
window
.
gameVars
.
wheat
.
sold
$
(
'td#stats-livestock-consumed'
).
html
window
.
gameVars
.
liveStock
.
produced
$
(
'td#stats-livestock-consumed'
).
html
window
.
gameVars
.
liveStock
.
consumed
$
(
'td#stats-livestock-bought'
).
html
window
.
gameVars
.
liveStock
.
bought
$
(
'td#stats-livestock-sold'
).
html
window
.
gameVars
.
liveStock
.
sold
$
(
'td#stats-fields-bought'
).
html
window
.
gameVars
.
fields
.
bought
$
(
'td#stats-fields-sold'
).
html
window
.
gameVars
.
fields
.
sold
$
(
'td#stats-cattle-bought'
).
html
window
.
gameVars
.
cattleGrid
.
bought
$
(
'td#stats-cattle-sold'
).
html
window
.
gameVars
.
cattleGrid
.
sold
$
(
'span#valuables-gold'
).
html
0
if
window
.
gameVars
.
gold
<
0
$
(
'span#goods-wheat'
).
html
0
if
window
.
gameVars
.
wheat
.
count
<
0
...
...
@@ -66,6 +76,7 @@ updateCounters = ->
if
window
.
gameVars
.
wheat
.
count
<=
0
window
.
clearInterval
evtim
window
.
clearInterval
fitim
window
.
clearInterval
whtim
$
(
'#game-over-modal'
).
modal
'show'
# Field Timer
...
...
@@ -74,6 +85,17 @@ fieldTimer = ->
window
.
gameVars
.
wheat
.
produced
+=
window
.
gameVars
.
fields
.
count
updateCounters
()
# Wheat Timer
wheatTimer
=
->
if
window
.
gameVars
.
liveStock
.
count
<=
0
c
=
(
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
shelter
)
*
2
else
c
=
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
shelter
window
.
gameVars
.
wheat
.
count
-=
c
window
.
gameVars
.
wheat
.
consumed
+=
c
updateCounters
()
#Krieg
warTimer
=
->
die
=
Math
.
floor
((
Math
.
random
()
*
10000000
)
%
2
)
==
0
...
...
@@ -174,5 +196,6 @@ eventTimer = ->
evtim
=
window
.
setInterval
eventTimer
,
30000
fitim
=
window
.
setInterval
fieldTimer
,
100
whtim
=
window
.
setInterval
wheatTimer
,
100
$
(
document
).
ready
->
updateCounters
()
js/main.js
View file @
d717f845
// Generated by CoffeeScript 1.7.1
(
function
()
{
var
eventTimer
,
evtim
,
fieldTimer
,
fitim
,
initItem
,
updateCounters
,
warTimer
;
var
eventTimer
,
evtim
,
fieldTimer
,
fitim
,
initItem
,
updateCounters
,
warTimer
,
wheatTimer
,
whtim
;
initItem
=
function
(
defaultCount
,
consumable
)
{
var
retobj
;
...
...
@@ -17,7 +17,7 @@
};
window
.
gameVars
=
{
cattleGrid
s
:
initItem
(
1
,
false
),
cattleGrid
:
initItem
(
1
,
false
),
fields
:
initItem
(
1
,
false
),
gold
:
200
,
people
:
{
...
...
@@ -52,9 +52,19 @@
$
(
'
span#people-shelter
'
).
html
(
window
.
gameVars
.
people
.
shelter
);
$
(
'
span#people-all
'
).
html
(
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
war
+
window
.
gameVars
.
people
.
shelter
);
$
(
'
span#builds-fields
'
).
html
(
window
.
gameVars
.
fields
.
count
);
$
(
'
span#builds-cattle
'
).
html
(
window
.
gameVars
.
cattleGrid
s
.
count
);
$
(
'
span#builds-cattle
'
).
html
(
window
.
gameVars
.
cattleGrid
.
count
);
$
(
'
td#stats-wheat-produced
'
).
html
(
window
.
gameVars
.
wheat
.
produced
);
$
(
'
td#stats-wheat-consumed
'
).
html
(
window
.
gameVars
.
wheat
.
consumed
);
$
(
'
td#stats-wheat-bought
'
).
html
(
window
.
gameVars
.
wheat
.
bought
);
$
(
'
td#stats-wheat-sold
'
).
html
(
window
.
gameVars
.
wheat
.
sold
);
$
(
'
td#stats-livestock-consumed
'
).
html
(
window
.
gameVars
.
liveStock
.
produced
);
$
(
'
td#stats-livestock-consumed
'
).
html
(
window
.
gameVars
.
liveStock
.
consumed
);
$
(
'
td#stats-livestock-bought
'
).
html
(
window
.
gameVars
.
liveStock
.
bought
);
$
(
'
td#stats-livestock-sold
'
).
html
(
window
.
gameVars
.
liveStock
.
sold
);
$
(
'
td#stats-fields-bought
'
).
html
(
window
.
gameVars
.
fields
.
bought
);
$
(
'
td#stats-fields-sold
'
).
html
(
window
.
gameVars
.
fields
.
sold
);
$
(
'
td#stats-cattle-bought
'
).
html
(
window
.
gameVars
.
cattleGrid
.
bought
);
$
(
'
td#stats-cattle-sold
'
).
html
(
window
.
gameVars
.
cattleGrid
.
sold
);
if
(
window
.
gameVars
.
gold
<
0
)
{
$
(
'
span#valuables-gold
'
).
html
(
0
);
}
...
...
@@ -64,6 +74,7 @@
if
(
window
.
gameVars
.
wheat
.
count
<=
0
)
{
window
.
clearInterval
(
evtim
);
window
.
clearInterval
(
fitim
);
window
.
clearInterval
(
whtim
);
return
$
(
'
#game-over-modal
'
).
modal
(
'
show
'
);
}
};
...
...
@@ -74,6 +85,18 @@
return
updateCounters
();
};
wheatTimer
=
function
()
{
var
c
;
if
(
window
.
gameVars
.
liveStock
.
count
<=
0
)
{
c
=
(
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
shelter
)
*
2
;
}
else
{
c
=
window
.
gameVars
.
people
.
home
+
window
.
gameVars
.
people
.
shelter
;
}
window
.
gameVars
.
wheat
.
count
-=
c
;
window
.
gameVars
.
wheat
.
consumed
+=
c
;
return
updateCounters
();
};
warTimer
=
function
()
{
var
die
,
g
,
message
,
title
;
die
=
Math
.
floor
((
Math
.
random
()
*
10000000
)
%
2
)
===
0
;
...
...
@@ -188,6 +211,8 @@
fitim
=
window
.
setInterval
(
fieldTimer
,
100
);
whtim
=
window
.
setInterval
(
wheatTimer
,
100
);
$
(
document
).
ready
(
function
()
{
return
updateCounters
();
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment