Skip to content
This repository was archived by the owner on Dec 5, 2020. It is now read-only.

Commit 76dd1a0

Browse files
committed
Build files
1 parent c82034f commit 76dd1a0

File tree

2 files changed

+912
-0
lines changed

2 files changed

+912
-0
lines changed

build-demo.js

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
2+
/*
3+
4+
GENERAL FUNCTIONS
5+
6+
*/
7+
8+
/**
9+
Generates item states, so all items have the same
10+
*/
11+
function itemStats(options){
12+
var o={
13+
// Life of the cell. -1 is infinite, 0 is dead;
14+
life:-1,
15+
// Attack power
16+
damage:0,
17+
// Strenght level
18+
strenght:0,
19+
// Current level (maybe that should be calculated from XP)
20+
level:1,
21+
// Current experience
22+
xp:0,
23+
// How much xp is won with this
24+
giveXp:0
25+
};
26+
27+
// Filling properties
28+
for(let i in o){
29+
if(options[i]!=undefined){o[i]=options[i];}
30+
}
31+
return o;
32+
}
33+
34+
/**
35+
Represents an item (static item, ennemy, player,...)
36+
@constructor
37+
*/
38+
var Item=function(options){
39+
var o={
40+
name:'NO NAME',
41+
description: 'NO DESCRIPTION',
42+
canMove:false,
43+
storable: false,
44+
consumable: false,
45+
effects:[],
46+
inventory:[],
47+
stats:{},
48+
className:'item',
49+
};
50+
// Filling properties
51+
for(let i in o){
52+
if(options[i]!=undefined){this[i]=options[i];}
53+
else{this[i]=o[i];}
54+
}
55+
};
56+
57+
// Ennemies are created dynamically with this function:
58+
function createEnnemies(type, playerLevel, walkableCells, number){
59+
var nb=0;
60+
if(number!=undefined){
61+
nb=number;
62+
}else{
63+
nb=Math.floor(5*walkableCells/100);
64+
}
65+
// Number of ennemies to generate:
66+
var ennemies={};
67+
for(let i=0; i<nb; i++){
68+
// Select random ennemy
69+
let ennemy=ennemyNames[Math.floor(Math.random()*ennemyNames.length)];
70+
let ennemyStats={};
71+
// Generate random states
72+
var randomGen=Math.floor(Math.random()*101);
73+
if(randomGen<80){
74+
ennemyStats.life=basePlayerStats.life*0.8;
75+
ennemyStats.damage=basePlayerStats.damage;
76+
ennemyStats.strenght=basePlayerStats.strenght;
77+
ennemyStats.level=basePlayerStats.level;
78+
ennemyStats.giveXp=ennemyStats.level*10;
79+
}else if (randomGen<90) {
80+
ennemyStats.life=basePlayerStats.life*1.1;
81+
ennemyStats.damage=Math.ceil(basePlayerStats.damage*(Math.floor(Math.random()*0.2)+1));
82+
ennemyStats.strenght=Math.ceil(basePlayerStats.strenght*(Math.floor(Math.random()*0.2)+1));
83+
ennemyStats.level=basePlayerStats.level+1;
84+
ennemyStats.giveXp=ennemyStats.level*20;
85+
}else if(randomGen<97) {
86+
ennemyStats.life=basePlayerStats.life*1.4;
87+
ennemyStats.damage=Math.ceil(basePlayerStats.damage*(Math.floor(Math.random()*0.4)+1));
88+
ennemyStats.strenght=Math.ceil(basePlayerStats.strenght*(Math.floor(Math.random()*0.4)+1));
89+
ennemyStats.level=basePlayerStats.level+2;
90+
ennemyStats.giveXp=ennemyStats.level30;
91+
}else{
92+
ennemyStats.life=basePlayerStats.life*1.6;
93+
ennemyStats.damage=Math.ceil(basePlayerStats.damage*(Math.floor(Math.random()*0.6)+1));
94+
ennemyStats.strenght=Math.ceil(basePlayerStats.strenght*(Math.floor(Math.random()*0.6)+1));
95+
ennemyStats.level=basePlayerStats.level+3;
96+
ennemyStats.giveXp=ennemyStats.level*40;
97+
}
98+
99+
living_things[type+'_'+i]=new Item({
100+
name:ennemy.name,
101+
description:ennemy.description+' <a href="'+ennemy.more+'" target="_blank">More...</a>',
102+
canMove:true,
103+
stats: itemStats(ennemyStats),
104+
className: (number===1?'boss': 'ennemy'),
105+
})
106+
}
107+
}
108+
109+
function createSimpleItem(name, walkableCells, percent, number){
110+
var nb=0;
111+
if(number!=undefined){
112+
nb=number
113+
}else{
114+
nb=Math.floor((walkableCells*Math.random()*percent)/100)
115+
}
116+
for(i=0; i<nb; i++){
117+
dead_things[name+'_'+i]=new Item(availableItems[name]);
118+
}
119+
}
120+
121+
/*
122+
123+
OBJECTS CONFIGURATION
124+
125+
*/
126+
127+
var bossNames=[
128+
{name:'Acará virus', description:'The Acará virus (ACAV) is a possible species in the genus Bunyavirus, belonging to the Capim serogroup. It is isolated from sentinel mice, Culex species, and the rodent Nectomys squamipes in Para, Brazil and in Panama. The symptoms of the Acará virus is death. Sometimes reported to cause disease in humans.', more:'https://en.wikipedia.org/wiki/Acar%C3%A1_virus'},
129+
{name:'Banana virus X', description:'Cafeteria roenbergensis virus (CroV) is a giant virus that infects the marine bicosoecid flagellate Cafeteria roenbergensis. CroV has one of the largest genomes of all marine virus known, consisting of ~730,000 base pairs of double-stranded DNA', more:'https://en.wikipedia.org/wiki/Cafeteria_roenbergensis_virus'},
130+
{name:'Mokola virus', description:'Mokola virus (MOKV) is a RNA virus related to the Rabies virus that has been sporadically isolated from mammals across sub-Saharan Africa. The majority of isolates have come from domestic cats exhibiting symptoms characteristically associated to Rabies virus infection.', more:'https://en.wikipedia.org/wiki/Mokola_virus'},
131+
{name:'Nipah Virus', description:'Nipah virus was identified in April 1999, when it caused an outbreak of neurological and respiratory disease on pig farms in peninsular Malaysia, resulting in 257 human cases, including 105 human deaths and the culling of one million pigs.', more:'https://en.wikipedia.org/wiki/Henipavirus#Nipah_virus'},
132+
]
133+
var ennemyNames=[
134+
// Lazy me... http://alltoptens.com/top-ten-most-dangerous-bacteria-on-earth/
135+
// This list was completed with wikipedia articles and some names has been changed or removed when info wasn't clear enough.
136+
{name:'Escherichia coli', description:'Virulent strains can cause gastroenteritis, urinary tract infections, and neonatal meningitis. It can also be characterized by severe abdominal cramps, diarrhea that typically turns bloody within 24 hours, and sometimes fever.', more:'https://en.wikipedia.org/wiki/Escherichia_coli'},
137+
{name:'Clostridium Botulinum', description:'Infection with the bacterium may result in a potentially fatal disease called botulism. Botulinum is the most acutely lethal toxin known, with an estimated human median lethal dose (LD50) of 1.3–2.1 ng/kg intravenously or intramuscularly and 10–13 ng/kg when inhaled.', more:'https://en.wikipedia.org/wiki/Botulinum_toxin'},
138+
{name:'Salmonella', description:'Strains of Salmonella cause illnesses such as typhoid fever, paratyphoid fever, and food poisoning (salmonellosis).', more:'https://en.wikipedia.org/wiki/Salmonella'},
139+
{name:'Vibrio cholera', description:'Cholera affects an estimated 3–5 million people worldwide and causes 58,000–130,000 deaths a year as of 2010.While it is currently classified as a pandemic, it is rare in the developed world. Children are mostly affected.', more:'https://en.wikipedia.org/wiki/Cholera'},
140+
{name:'Clostridium tetani', description:'Tetanus toxin is a potent neurotoxin. On the basis of weight, tetanospasmin is one of the most potent toxins known (based on tests conducted on mice). The estimated minimum human lethal dose is 2.5 nanograms per kilogram of body weight, or 175 nanograms in a 70 kg (154 lb) human.', more:'https://en.wikipedia.org/wiki/Clostridium_tetani'},
141+
{name:'Aspergillus fumigatus', description:'An ubiquitous organism that is capable of living under extensive environmental stress. It is estimated that most humans inhale thousands of Aspergillus spores daily, but they do not affect most people’s health due to effective immune responses. Taken together, the major chronic, invasive and allergic forms of aspergillosis account for around 600,000 deaths annually worldwide.', more:'https://en.wikipedia.org/wiki/Aspergillosis'},
142+
{name:'Treponema pallidum', description:'Treponema pallidum is a spirochaete bacterium with subspecies that cause treponemal diseases such as syphilis, bejel, pinta, and yaws. The treponemes have a cytoplasmic and an outer membrane. Using light microscopy, treponemes are only visible using dark field illumination.', more:'https://en.wikipedia.org/wiki/Treponema_pallidum'},
143+
{name:'Streptococcus', description:'In addition to streptococcal pharyngitis (strep throat), certain Streptococcus species are responsible for many cases of pink eye, meningitis, bacterial pneumonia, endocarditis, erysipelas, and necrotizing fasciitis (the \'flesh-eating\' bacterial infections).', more:'https://en.wikipedia.org/wiki/Streptococcus'},
144+
{name:'Mycobacterium tuberculosis', description:'Tuberculosis generally affects the lungs, but can also affect other parts of the body. Most infections do not have symptoms, known as latent tuberculosis. About 10% of latent infections progress to active disease which, if left untreated, kills about half of those infected.', more:'https://en.wikipedia.org/wiki/Tuberculosis'},
145+
]
146+
147+
// Base player stats
148+
var basePlayerStats={life:50, damage:10, strenght:1, level:1};
149+
150+
// Player
151+
// For ennemies and bosses, this should be filled after map generation, as the createEnnemies function
152+
// needs infos baout the map.
153+
var living_things={
154+
player: new Item({name:'Leukocyt', description: 'You, a white globule', canMove:true, stats: itemStats(basePlayerStats), className:'player'}),
155+
}
156+
var dead_things={};
157+
158+
// Pickable items
159+
var availableItems={
160+
life_potion: {name:'Life potion', description: 'Gives you 50 points of life', storable:false, consumable:true, className:'health'},
161+
token_strength: {name:'Token of strenght', description: 'Adds 1 to your strenght', storable:true, consumable:false, className:'chest'},
162+
token_damage: {name:'Token of damage', description: 'Adds 1 to your damage', storable:true, consumable:false, className:'chest'},
163+
};
164+
165+
// Cell types used to generate the map
166+
var cellTypes={
167+
wall: {name:'wall', isWalkable:false, classNames:['wall'], isBaseCell:true},
168+
floor: {name:'floor', isWalkable:true, classNames:['floor'], isBaseCell:true},
169+
lava: {name:'lava', isWalkable:true, classNames:['lava'], damage:1},
170+
water: {name:'water', isWalkable:true, classNames:['water']},
171+
};
172+
var samples=[
173+
// Square rooms
174+
[
175+
'00000000000000000',
176+
'01110001110001110',
177+
'01110001110001110',
178+
'01110001110001110',
179+
'00000000000000000',
180+
'00000000000000000',
181+
'00000000000000000',
182+
'01110001110001110',
183+
'01110001110001110',
184+
'01110001110001110',
185+
'00000000000000000',
186+
'00000000000000000',
187+
'00000000000000000',
188+
'01110001110001110',
189+
'01110001110001110',
190+
'01110001110001110',
191+
'00000000000000000',
192+
],
193+
// Triangles
194+
[
195+
'00000000000000000',
196+
'01111100000000010',
197+
'01111000000000110',
198+
'01110000000001110',
199+
'01100000000011110',
200+
'01000000000111110',
201+
'00000000001111110',
202+
'01000000000111110',
203+
'01100000000011110',
204+
'01110000000001110',
205+
'01111000000000110',
206+
'01111100000000010',
207+
'00000000000000000',
208+
],
209+
// Triangles2
210+
[
211+
'00000000000000000',
212+
'01111100000000010',
213+
'01111000000000110',
214+
'01110000000001110',
215+
'01100000000011110',
216+
'01000000000111110',
217+
'00000000001111110',
218+
'01000000000111110',
219+
'01100001000011110',
220+
'01110001100001110',
221+
'01111001000000110',
222+
'01111100000000010',
223+
'00000000000000000',
224+
]
225+
];

0 commit comments

Comments
 (0)