-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfactory.js
147 lines (135 loc) · 3.25 KB
/
factory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
var batteryDisplay = true;
//master factory function for the event listener, pretty trashy atm
function factoryFunction(value) {
if (value == 'place_one') {
plantSeed();
}
else if (value == 'place_all') {
plantAll();
}
else if (value == 'use_battery') {
useBattery();
}
else if (value == 'make_flesh') {
createFlesh();
}
if (batteryDisplay == false) {
batteryEnable();
}
}
function createFlesh() {
if ((player.money > 0 ) && (player.gunk > 0)) {
if (player.money > player.gunk) {
flesh = player.gunk;
}
else {
flesh = player.money;
}
if (flesh > 5000) {
player.num = 7.5;
}
if (flesh > 10000) {
player.num = 10;
}
if (flesh > 50000) {
player.num = 20;
}
if (flesh > 100000) {
player.num = 30;
}
if (flesh > 200000) {
player.num = 50;
}
player.money = player.money - flesh;
player.gunk = player.gunk - flesh;
player.maxHealth = player.maxHealth + Math.round(flesh / player.num);
flesh = 0;
player.num = 5;
if (player.maxHealth > player.maximum) {
player.maxHealth = player.maximum;
}
$('#blood').html('You have ' + player.gunk + ' gunk');
}
}
//functions associated with the factory, placegears/usebatteries
function plantSeed() {
if (inventoryObject.seed > 0) {
player.gears++;
inventoryObject.seed--;
$('#seeds_planted').html("Gears Placed: " + player.gears);
}
else {
error.innerHTML = 'you have no gears';
}
}
function plantAll() {
if (inventoryObject.seed > 0) {
player.gears = player.gears + inventoryObject.seed;
inventoryObject.seed = 0;
$('#seeds_planted').html("Gears Placed: " + player.gears);
}
else {
error.innerHTML = 'you have no gears';
}
}
function batteryEnable() {
if (player.gears > 1) {
$('#batteryButton').css('display', 'inline');
batteryDisplay = true;
batteryOn = true;;
}
}
function useBattery() {
if (inventoryObject.battery > 0) {
player.batteries++;
inventoryObject.battery--;
}
else {
error.innerHTML = 'you have no batteries';
}
}
function turnOffBattery() {
if (batteryOn == false) {
batteryOn = true;
$('#blood_gen').html('gunk/s: ' + player.batteries*2);
$('#turn_off').html('Turn Off Machine');
}
else {
batteryOn = false;
$('#blood_gen').html('The machine is off');
$('#turn_off').html('Turn On Machine');
}
}
//generates ectoplasm on click
function ectoplasmClick(num) {
player.money = player.money + num;
document.getElementById('ectoplasm').innerHTML = "You have " + player.money + " gold";
}
//generates ectoplasm overtime, passing in gears placed
function ectoplasmGenerator(num) {
player.money = player.money + num*player.extraMoneyGen;
$('#ecto_gen').html('gold/s: ' + num);
updateResources();
hideClickButton();
}
//hides/shows click button if over/under 1000 money
function hideClickButton() {
if (player.money > 1000) {
$('#click_button').hide();
}
else if (player.money < 1000) {
$('#click_button').show();
}
}
//generates blood overtime, passing in batteries placed
function bloodGenerator(num) {
if (num * 2 <= player.money) {
player.gunk = player.gunk + num*2;
player.money = player.money - num*2;
$('#blood_gen').html('gunk/s: ' + num*2);
}
}
function updateResources() {
$('#blood').html('You have ' + player.gunk + ' gunk');
$('#ectoplasm').html('You have ' + player.money + ' gold');
}