-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stockemon.js
213 lines (183 loc) · 7.69 KB
/
Stockemon.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
var typeEnum = {
SWORD: "w",
SHIELD: "h",
STAFF: "t",
WOOD: "0"
};
var StockemonEnum = {
Stock: { type: "0", entwicklung: 0, name: "Stock", atk: 3, def: 1, luc: 1, hp_max: 10, g: "m" },
//Schwerter
Schwert: { type: "w", name: "Schwert", entwicklung: 1, g: "n", atk: 3, def: 1, luc: 1, hp_max: 13 },
Langschwert: { type: "w", name: "Langschwert", entwicklung: 2, g: "n", atk: 5, def: 3, luc: 3, hp_max: 25 },
Zweihaender: { type: "w", name: "Zweihaender", entwicklung: 3, g: "m", atk: 11, def: 2, luc: 3, hp_max: 38 },
GreatSword: { type: "w", name: "Aua Aua", entwicklung: 4, g: "n", atk: 17, def: 4, luc: 5, hp_max: 50 },
//Schilde
Griff_mit_Brett: { type: "h", name: "Griff mit Brett", entwicklung: 1, g: "m", atk: 2, def: 2, luc: 1, hp_max: 19 },
Schild: { type: "h", name: "Schild", entwicklung: 2, g: "n", atk: 3, def: 5, luc: 14, hp_max: 35 },
Grossschild: { type: "h", name: "Grossschild", entwicklung: 3, g: "n", atk: 7, def: 9, luc: 17, hp_max: 60 },
Igelschild: { type: "h", name: "Pieks Pieks", entwicklung: 4, g: "n", atk: 11, def: 13, luc: 20, hp_max: 100 },
//Staebe
Speer: { type: "t", name: "Speer", entwicklung: 1, g: "m", atk: 2, def: 2, luc: 2, hp_max: 15 },
Hellebarde: { type: "t", name: "Hellebarde", entwicklung: 2, g: "f", atk: 4, def: 4, luc: 8, hp_max: 30 },
Dreizack: { type: "t", name: "Dreizack", entwicklung: 3, g: "m", atk: 9, def: 11, luc: 9, hp_max: 49 },
Pikspikspiks: { type: "t", name: "Aua Pieks", entwicklung: 4, g: "n", atk: 14, def: 8, luc: 12, hp_max: 75 },
//Tannenbaum!!!
Tannenbaum: { type: "0", name: "Tannenbaum", entwicklung: 5, g: "m", atk: 42, def: 42, luc: 42, hp_max: 4242, action: "Ho!Ho!Ho!" }
};
function Stockemon(type, entwicklung, level) {
//Stockemon class
//fixed attributes first
var multiplicator = 1.05;
this.loadValues = function (type, entwicklung, level) {
this.lvl = level;
this.evolution = entwicklung;
this.type = type;
for (var stockKey in StockemonEnum) {
var stock = StockemonEnum[stockKey];
if (stock.type == type && stock.entwicklung == entwicklung) {
this.hp_max = (stock.hp_max * Math.pow(multiplicator, level)).toFixed(0);
this.atk = (stock.atk * Math.pow(multiplicator, level)).toFixed(0);
this.def = (stock.def * Math.pow(multiplicator, level)).toFixed(0);
this.luc = (stock.luc * Math.pow(multiplicator, level)).toFixed(0);
this.epTillLvlUp = Math.floor(15 * Math.pow(multiplicator, level));
this.epOnDeath = Math.floor(2 * Math.pow(multiplicator, level*2));
this.name = stock.name;
this.gender = stock.g;
this.actions = [4];
for (var i = 0; i < 4; ++i) this.actions[i] = new Action(actionEnum.Stupsen); //First set all to default
var actionsindex = 0;
for (var actionKey in actionEnum) {
var action = actionEnum[actionKey];
if ((type == action.type || type == "0") && entwicklung >= action.neededEvo && level >= action.neededLvl) {
this.actions[actionsindex] = new Action(action);
actionsindex++;
actionsindex %= 4;
}
}
break;
}
}
}
this.loadValues(type, entwicklung, level);
this.hp_current = this.hp_max;
this.poison = [];
this.blocked_dmg = 0;
this.getInfo = function () {
return '' + this.name + ' LVL:' + this.lvl + ' HP:' + this.hp_current + ' / ' + this.hp_max;
};
this.getBattleInfo = function () {
return this.name + ' LVL:' + this.lvl + ' HP:' + this.hp_current + ' / ' + this.hp_max + ' POISON:' + this.poison[0];
};
this.heal = function () {
this.hp_current = this.hp_max;
//TODO Interface function: Just healed
}
this.setAction = function (action, index) {
actions[index] = action;
}
this.onTick = function () {
if (this.poison == []) return;
var damage = this.poison[0];
this.onDamage(damage);
this.poison.shift();
return damage;
}
this.onDamage = function (amount) {
var damage = Math.floor(amount / this.def);
damage = Math.floor(Math.max(0, damage - this.blocked_dmg));
this.blocked_dmg = 0;
this.hp_current -= damage;
//TODO add Interface function (display damage taken)
if (this.hp_current < 0) {
this.onDeath();
}
return damage;
}
this.onDeath = function () {
//TODO Interface function (player died action)
this.hp_current = 0;
this.onLostFight();
}
this.onLostFight = function () {
//TODO Interface function
}
this.attackEnemy = function (action, enemy) {
var damage = action.dmg * this.atk * ((Math.random() * this.luc - 0.5) * 0.05 + 1);
damage = Math.floor(damage);
damage = enemy.onDamage(damage);
this.blocked_dmg = Math.floor(action.dmg_reduce * this.def * ((Math.random() * this.luc - 0.5) * 0.05 + 1));
return damage;
}
this.getEP = function (ep) {
this.epTillLvlUp -= ep;
while (this.epTillLvlUp <= 0) {
var add = this.epTillLvlUp;
this.loadValues(this.type, this.evolution, ++this.lvl);
this.epTillLvlUp += add;
}
}
this.getInfo = function () {
// format: atk def luc max_hp eptolvlup lvl
var code = this.atk + " " + this.def + " " + this.luc + " " + this.hp_max + " " + this.epTillLvlUp + " " + this.lvl + " " + this.type + " ";
var entwicklung = this.evolution;
if (entwicklung == 5)
code += "GerdLiebtKekse";
else if (entwicklung == 4) {
code += "KekseSindToll";
} else if (entwicklung == 3) {
code += "AlleDieKekseMoegenSindToll";
} else if (entwicklung == 2) {
code += "StockeMonKommSchlagSieAlle";
} else if (entwicklung == 1) {
code += "AdventAdventEinStockMonSchlaegt";
} else if (entwicklung == 0) {
code += "StockStockWerIstDa";
}
return code; //this.type + ' LVL:' + this.lvl + 'Hungry:' + this.hungry + 'Sleepy:' + this.sleepy + 'Happy:' + this.happy + 'Dirty:' + this.dirty;
};
this.setInfo = function () {
var current = this.getInfo();
var n = prompt("Dein Stockemon-Code:", current);
if (n != n || n == null || n == undefined)
return;
var ss = n.split(" ");
if (n.length < 8)
return;
var satk = ss[0];
var sdef = ss[1];
var sluc = ss[2];
var smax_hp = ss[3];
var septolvlup = ss[4];
var slvl = ss[5];
var stype = ss[6];
var n = ss[7];
this.lvl = slvl;
this.type = stype;
if (n == "GerdLiebtKekse") {
this.evolution = 5;
}
if (n == "KekseSindToll") {
this.evolution = 4;
}
if (n == "AlleDieKekseMoegenSindToll") {
this.evolution = 3;
}
if (n == "StockeMonKommSchlagSieAlle") {
this.evolution = 2;
}
if (n == "AdventAdventEinStockMonSchlaegt") {
this.evolution = 1;
}
if (n == "StockStockWerIstDa") {
this.evolution = 0;
}
this.loadValues(stype, this.evolution, slvl);
this.atk = parseInt(satk);
this.def = parseInt(sdef);
this.luc = parseInt(sluc);
this.hp_max = parseInt(smax_hp);
this.heal();
this.epTillLvlUp = parseInt(septolvlup);
};
};