test2
This commit is contained in:
parent
79deb57579
commit
c845fa0e9b
1 changed files with 145 additions and 144 deletions
195
js/script.js
195
js/script.js
|
@ -1,54 +1,55 @@
|
||||||
const Biome = {
|
const Biome = {
|
||||||
WATER_DEEP: { acceptStructure:false, movements:['swim'], affinities:[('water',0.8),('dark',0.2)], name: 'Eau Profonde', winterColor: '#3D5A80', fallColor: '#3D5A80', summerColor: '#3D5A80', autumnColor: '#3D5A80',maxElevation:-1,minElevation:-4 },
|
WATER_DEEP: { acceptStructure: false, movements: ['swim'], affinities: [('water', 0.8), ('dark', 0.2)], name: 'Eau Profonde', winterColor: '#3D5A80', fallColor: '#3D5A80', summerColor: '#3D5A80', autumnColor: '#3D5A80', maxElevation: -1, minElevation: -4 },
|
||||||
WATER_SHALLOW: { acceptStructure:false,movements:['swim','ride','navigate','fly'], affinities:[('water',0.8),('life',0.2)],name: 'Eau Peu Profonde', winterColor: '#97aabdff', fallColor: '#5A8AB8', summerColor: '#5A8AB8', autumnColor: '#5A8AB8',maxElevation:1,minElevation:-2 },
|
WATER_SHALLOW: { acceptStructure: false, movements: ['swim', 'ride', 'navigate', 'fly'], affinities: [('water', 0.8), ('life', 0.2)], name: 'Eau Peu Profonde', winterColor: '#97aabdff', fallColor: '#5A8AB8', summerColor: '#5A8AB8', autumnColor: '#5A8AB8', maxElevation: 1, minElevation: -2 },
|
||||||
BEACH: { acceptStructure:true, movements:['walk','ride','fly'],affinities:[('sand',0.8),('water',0.2)],name: 'Sable', winterColor: '#E9D9A1', fallColor: '#E9D9A1', summerColor: '#E9D9A1', autumnColor: '#E9D9A1',maxElevation:2 ,minElevation:0 },
|
BEACH: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('sand', 0.8), ('water', 0.2)], name: 'Sable', winterColor: '#E9D9A1', fallColor: '#E9D9A1', summerColor: '#E9D9A1', autumnColor: '#E9D9A1', maxElevation: 2, minElevation: 0 },
|
||||||
GRASSLAND: { acceptStructure:true, movements:['walk','ride','fly'],affinities:[('life',0.6),('earth',0.2)],name: 'Plaine', winterColor: '#ecf1e3ff', fallColor: '#98C159', summerColor: '#a5a450ff', autumnColor: '#455e21ff',maxElevation:3,minElevation:-1 },
|
GRASSLAND: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('life', 0.6), ('earth', 0.2)], name: 'Plaine', winterColor: '#ecf1e3ff', fallColor: '#98C159', summerColor: '#a5a450ff', autumnColor: '#455e21ff', maxElevation: 3, minElevation: -1 },
|
||||||
FOREST: { acceptStructure:true,movements:['walk','ride','fly'],affinities:[('wood',0.6),('earth',0.4)], name: 'Forêt', winterColor: '#92ac83ff', fallColor: '#21a32cff', summerColor: '#6A994E', autumnColor: '#b88a28ff',maxElevation:3,minElevation:0 },
|
FOREST: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('wood', 0.6), ('earth', 0.4)], name: 'Forêt', winterColor: '#92ac83ff', fallColor: '#21a32cff', summerColor: '#6A994E', autumnColor: '#b88a28ff', maxElevation: 3, minElevation: 0 },
|
||||||
ENCHANTED_FOREST: { acceptStructure:true,movements:['walk','ride','fly'],affinities:[('wood',0.8),('dark',0.2)('life',0.2)], name: 'Forêt Enchantée', winterColor: '#7B6094', fallColor: '#7B6094', summerColor: '#7B6094', autumnColor: '#7B6094',maxElevation:3,minElevation:0 },
|
ENCHANTED_FOREST: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('wood', 0.8), ('dark', 0.2)('life', 0.2)], name: 'Forêt Enchantée', winterColor: '#7B6094', fallColor: '#7B6094', summerColor: '#7B6094', autumnColor: '#7B6094', maxElevation: 3, minElevation: 0 },
|
||||||
MOUNTAIN: { acceptStructure:false, movements:['climb','fly'],affinities:[('rock',0.6),('wind',0.4)],name: 'Montagne', winterColor: '#F7F7F7', fallColor: '#A9A9A9', summerColor: '#A9A9A9', autumnColor: '#A9A9A9',maxElevation:4,minElevation:3 },
|
MOUNTAIN: { acceptStructure: false, movements: ['climb', 'fly'], affinities: [('rock', 0.6), ('wind', 0.4)], name: 'Montagne', winterColor: '#F7F7F7', fallColor: '#A9A9A9', summerColor: '#A9A9A9', autumnColor: '#A9A9A9', maxElevation: 4, minElevation: 3 },
|
||||||
SNOWLAND: { acceptStructure:true,movements:['walk','ride','fly'], affinities:[('ice',0.8),('earth',0.2)],name: 'Toundra', winterColor: '#F7F7F7', fallColor: '#F7F7F7', summerColor: '#F7F7F7', autumnColor: '#F7F7F7',maxElevation:2,minElevation:-1 },
|
SNOWLAND: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('ice', 0.8), ('earth', 0.2)], name: 'Toundra', winterColor: '#F7F7F7', fallColor: '#F7F7F7', summerColor: '#F7F7F7', autumnColor: '#F7F7F7', maxElevation: 2, minElevation: -1 },
|
||||||
SNOWMOUNTAIN: { acceptStructure:false, movements:['climb','fly'],affinities:[('ice',0.4),('rock',0.4),('wind',0.2)],name: 'Mont enneigé', winterColor: '#F7F7F7', fallColor: '#F7F7F7', summerColor: '#F7F7F7', autumnColor: '#F7F7F7',maxElevation:4,minElevation:3 },
|
SNOWMOUNTAIN: { acceptStructure: false, movements: ['climb', 'fly'], affinities: [('ice', 0.4), ('rock', 0.4), ('wind', 0.2)], name: 'Mont enneigé', winterColor: '#F7F7F7', fallColor: '#F7F7F7', summerColor: '#F7F7F7', autumnColor: '#F7F7F7', maxElevation: 4, minElevation: 3 },
|
||||||
DESERT: { acceptStructure:true,movements:['walk','ride','fly'],affinities:[('sand',0.8),('life',0.1),('fire',0.1)], name: 'Désert', winterColor: '#D4A373', fallColor: '#D4A373', summerColor: '#D4A373', autumnColor: '#D4A373',maxElevation:2,minElevation:0 },
|
DESERT: { acceptStructure: true, movements: ['walk', 'ride', 'fly'], affinities: [('sand', 0.8), ('life', 0.1), ('fire', 0.1)], name: 'Désert', winterColor: '#D4A373', fallColor: '#D4A373', summerColor: '#D4A373', autumnColor: '#D4A373', maxElevation: 2, minElevation: 0 },
|
||||||
RIVER: { acceptStructure:false,movements:['navigate','swim','fly'],affinities:[('water',0.6),('earth',0.2),('life',0.2)],name: 'Rivière', winterColor: '#97aabdff', fallColor: '#5A8AB8', summerColor: '#5A8AB8', autumnColor: '#5A8AB8',maxElevation:2,minElevation:-2 },
|
RIVER: { acceptStructure: false, movements: ['navigate', 'swim', 'fly'], affinities: [('water', 0.6), ('earth', 0.2), ('life', 0.2)], name: 'Rivière', winterColor: '#97aabdff', fallColor: '#5A8AB8', summerColor: '#5A8AB8', autumnColor: '#5A8AB8', maxElevation: 2, minElevation: -2 },
|
||||||
SWAMP: { acceptStructure:false, movements:['fly'],affinities:[('water',0.6),('earth',0.2),('dark',0.2)],name: 'Marais', winterColor: '#0b2e10ff', fallColor: '#0b2e10ff', summerColor: '#0b2e10ff', autumnColor: '#0b2e10ff',maxElevation:1,minElevation:-1 }
|
SWAMP: { acceptStructure: false, movements: ['fly'], affinities: [('water', 0.6), ('earth', 0.2), ('dark', 0.2)], name: 'Marais', winterColor: '#0b2e10ff', fallColor: '#0b2e10ff', summerColor: '#0b2e10ff', autumnColor: '#0b2e10ff', maxElevation: 1, minElevation: -1 }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Affinities = ['water','fire','sand','rock','dark','life','ice','wood','wind','metal','time','space','lava','light','spirit']
|
const Affinities = ['water', 'fire', 'sand', 'rock', 'dark', 'life', 'ice', 'wood', 'wind', 'metal', 'time', 'space', 'lava', 'light', 'spirit']
|
||||||
|
|
||||||
const Slot = ['head','body','leg','foot','right-hand','left-hand','two-hands','finger1','finger2','neck','purse','backpack','belt1','belt2']
|
const Slot = ['head', 'body', 'leg', 'foot', 'right-hand', 'left-hand', 'two-hands', 'finger1', 'finger2', 'neck', 'purse', 'backpack', 'belt1', 'belt2']
|
||||||
|
|
||||||
const ItemType = {lightWeapon:{slot:('right-hand','left-hand','backpack'),soul:true,enchant:true},
|
const ItemType = {
|
||||||
heavyWeapon:{slot:('two-hands','backpack'),soul:true,enchant:true},
|
lightWeapon: { slot: ('right-hand', 'left-hand', 'backpack'), soul: true, enchant: true },
|
||||||
heavyArmor:{slot:('body','backpack'),soul:true,enchant:true},
|
heavyWeapon: { slot: ('two-hands', 'backpack'), soul: true, enchant: true },
|
||||||
lightArmor:{slot:('body','backpack'),soul:true,enchant:true},
|
heavyArmor: { slot: ('body', 'backpack'), soul: true, enchant: true },
|
||||||
shield:{slot:('right-hand','left-hand','backpack'),soul:true,enchant:true},
|
lightArmor: { slot: ('body', 'backpack'), soul: true, enchant: true },
|
||||||
shoes:{slot:('foot','backpack'),soul:true,enchant:true},
|
shield: { slot: ('right-hand', 'left-hand', 'backpack'), soul: true, enchant: true },
|
||||||
pant:{slot:('leg','backpack'),soul:true,enchant:true},
|
shoes: { slot: ('foot', 'backpack'), soul: true, enchant: true },
|
||||||
helmet:{slot:('leg','backpack'),soul:true,enchant:true},
|
pant: { slot: ('leg', 'backpack'), soul: true, enchant: true },
|
||||||
potion:{slot:('heal','backpack'),soul:false,enchant:false},
|
helmet: { slot: ('leg', 'backpack'), soul: true, enchant: true },
|
||||||
throwable:{slot:('belt','backpack'),soul:true,enchant:true},
|
potion: { slot: ('heal', 'backpack'), soul: false, enchant: false },
|
||||||
craftMaterial:{slot:('right-hand','left-hand','backpack'),soul:false,enchant:false},
|
throwable: { slot: ('belt', 'backpack'), soul: true, enchant: true },
|
||||||
ring:{slot:('finger1','finger2','backpack'),soul:true,enchant:true},
|
craftMaterial: { slot: ('right-hand', 'left-hand', 'backpack'), soul: false, enchant: false },
|
||||||
amulet:{slot:('neck','backpack'),soul:true,enchant:true},
|
ring: { slot: ('finger1', 'finger2', 'backpack'), soul: true, enchant: true },
|
||||||
currency:{slot:('purse'),soul:true,enchant:true},
|
amulet: { slot: ('neck', 'backpack'), soul: true, enchant: true },
|
||||||
enchantMaterial:{slot:('backpack'),soul:false,enchant:false},
|
currency: { slot: ('purse'), soul: true, enchant: true },
|
||||||
mercantMaterial:{slot:('backpack'),soul:false,enchant:false}
|
enchantMaterial: { slot: ('backpack'), soul: false, enchant: false },
|
||||||
|
mercantMaterial: { slot: ('backpack'), soul: false, enchant: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
const Items = {
|
const Items = {
|
||||||
'Épée en Bois': { name: 'Épée en Bois', itemType: 'lightWeapon', stats: { strength: 2 }, icon: '🗡️' ,enchantments:[] },
|
'Épée en Bois': { name: 'Épée en Bois', itemType: 'lightWeapon', stats: { strength: 2 }, icon: '🗡️', enchantments: [] },
|
||||||
'Armure de Cuir': { name: 'Armure de Cuir', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥',enchantments:[] },
|
'Armure de Cuir': { name: 'Armure de Cuir', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥', enchantments: [] },
|
||||||
'Claymore': { name: 'Claymore', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥',enchantments:['primal'] ,soul:new soul('cleaver','test')}
|
'Claymore': { name: 'Claymore', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥', enchantments: ['primal'], soul: new soul('cleaver', 'test') }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const StructureType = {
|
const StructureType = {
|
||||||
'Épée en Bois': { name: 'Épée en Bois', itemType: 'lightWeapon', stats: { strength: 2 }, icon: '🗡️' ,enchantments:[] },
|
'Épée en Bois': { name: 'Épée en Bois', itemType: 'lightWeapon', stats: { strength: 2 }, icon: '🗡️', enchantments: [] },
|
||||||
'Armure de Cuir': { name: 'Armure de Cuir', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥',enchantments:[] },
|
'Armure de Cuir': { name: 'Armure de Cuir', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥', enchantments: [] },
|
||||||
'Claymore': { name: 'Claymore', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥',enchantments:['primal'] ,soul:new soul('cleaver','test')}
|
'Claymore': { name: 'Claymore', itemType: 'lightArmor', stats: { vitality: 2 }, icon: '🧥', enchantments: ['primal'], soul: new soul('cleaver', 'test') }
|
||||||
};
|
};
|
||||||
|
|
||||||
const MONSTER_TYPES = {
|
const MONSTER_TYPES = {
|
||||||
GOBLIN: { name: 'Gobelin', icon: '👺', hp: 30, strength: 3, xp: 25, loot: { 'Or': 5 } },
|
GOBLIN: { name: 'Gobelin', icon: '👺', hp: 30, strength: 3, xp: 25, loot: { 'Or': 5 } },
|
||||||
|
@ -67,7 +68,7 @@ class world {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
}
|
}
|
||||||
setPosition(x,y,z) {
|
setPosition(x, y, z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
|
@ -82,12 +83,12 @@ class world {
|
||||||
|
|
||||||
class position {
|
class position {
|
||||||
|
|
||||||
constructor(x,y,z) {
|
constructor(x, y, z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
}
|
}
|
||||||
setPosition(x,y,z) {
|
setPosition(x, y, z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
|
@ -101,7 +102,7 @@ class position {
|
||||||
|
|
||||||
class tile {
|
class tile {
|
||||||
|
|
||||||
constructor(position,biome,elevation) {
|
constructor(position, biome, elevation) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
if (!Object.values(Biome).includes(biome)) {
|
if (!Object.values(Biome).includes(biome)) {
|
||||||
throw new Error('Biome invalide !');
|
throw new Error('Biome invalide !');
|
||||||
|
@ -117,7 +118,7 @@ class tile {
|
||||||
if (!Object.values(Biome).includes(biome)) {
|
if (!Object.values(Biome).includes(biome)) {
|
||||||
throw new Error('Biome invalide !');
|
throw new Error('Biome invalide !');
|
||||||
}
|
}
|
||||||
this.biome=biome;
|
this.biome = biome;
|
||||||
}
|
}
|
||||||
setBiome() {
|
setBiome() {
|
||||||
let scale = 0.05;
|
let scale = 0.05;
|
||||||
|
@ -137,19 +138,19 @@ class tile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setExplored(explored) {
|
setExplored(explored) {
|
||||||
this.explored=explored;
|
this.explored = explored;
|
||||||
}
|
}
|
||||||
setElevation(){
|
setElevation() {
|
||||||
this.elevation = Math.floor(Math.random() * (this.biome.maxElevation - this.biome.minElevation+ 1) + this.biome.minElevation);
|
this.elevation = Math.floor(Math.random() * (this.biome.maxElevation - this.biome.minElevation + 1) + this.biome.minElevation);
|
||||||
}
|
}
|
||||||
setStructure(){
|
setStructure() {
|
||||||
var structureChance = rand();
|
var structureChance = rand();
|
||||||
if (structureChance < 0.005) {
|
if (structureChance < 0.005) {
|
||||||
structure = { type: 'city', name: NAME_PREFIXES[Math.floor(rand() * NAME_PREFIXES.length)] + NAME_SUFFIXES[Math.floor(rand() * NAME_SUFFIXES.length)], population: 100 + Math.floor(rand() * 150), buildings: ['Remparts', 'Place Forte (Château)', 'Grand Marché', 'Forge', 'Alchimiste', 'Enchanteur', 'Écurie', 'Ferme', 'Ferme', 'Ferme', 'Ferme', 'Ferme', 'Lieu de Culte', 'Nombreuses Maisons'] };
|
structure = { type: 'city', name: NAME_PREFIXES[Math.floor(rand() * NAME_PREFIXES.length)] + NAME_SUFFIXES[Math.floor(rand() * NAME_SUFFIXES.length)], population: 100 + Math.floor(rand() * 150), buildings: ['Remparts', 'Place Forte (Château)', 'Grand Marché', 'Forge', 'Alchimiste', 'Enchanteur', 'Écurie', 'Ferme', 'Ferme', 'Ferme', 'Ferme', 'Ferme', 'Lieu de Culte', 'Nombreuses Maisons'] };
|
||||||
structureLocations.push({x, y, type: 'city'});
|
structureLocations.push({ x, y, type: 'city' });
|
||||||
} else if (structureChance < 0.02) {
|
} else if (structureChance < 0.02) {
|
||||||
structure = { type: 'village', name: NAME_PREFIXES[Math.floor(rand() * NAME_PREFIXES.length)] + NAME_SUFFIXES[Math.floor(rand() * NAME_SUFFIXES.length)], population: 20 + Math.floor(rand() * 20), buildings: ['Maison du Chef', 'Marchand', 'Lieu de Culte', 'Ferme', 'Ferme', 'Plusieurs Maisons'] };
|
structure = { type: 'village', name: NAME_PREFIXES[Math.floor(rand() * NAME_PREFIXES.length)] + NAME_SUFFIXES[Math.floor(rand() * NAME_SUFFIXES.length)], population: 20 + Math.floor(rand() * 20), buildings: ['Maison du Chef', 'Marchand', 'Lieu de Culte', 'Ferme', 'Ferme', 'Plusieurs Maisons'] };
|
||||||
structureLocations.push({x, y, type: 'village'});
|
structureLocations.push({ x, y, type: 'village' });
|
||||||
}
|
}
|
||||||
if (!this.tile && this.tile.biome === BIOMES.GRASSLAND && Math.random() < 0.2) {
|
if (!this.tile && this.tile.biome === BIOMES.GRASSLAND && Math.random() < 0.2) {
|
||||||
tile.isFarm = true;
|
tile.isFarm = true;
|
||||||
|
@ -158,7 +159,7 @@ class tile {
|
||||||
// npcs.push({ x: nx, y: ny, homeX: loc.x, homeY: loc.y, workX: nx, workY: ny, type: 'farmer', icon: '🧑🌾' });
|
// npcs.push({ x: nx, y: ny, homeX: loc.x, homeY: loc.y, workX: nx, workY: ny, type: 'farmer', icon: '🧑🌾' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class map {
|
class map {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.tiles = null;
|
this.tiles = null;
|
||||||
|
@ -168,7 +169,7 @@ class map {
|
||||||
this.elevation = 8;
|
this.elevation = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeMap(){
|
initializeMap() {
|
||||||
console.time('Map Generation');
|
console.time('Map Generation');
|
||||||
const simplex = new SimplexNoise();
|
const simplex = new SimplexNoise();
|
||||||
mapData = Array(this.map_size).fill(null).map((_, y) => Array(this.map_size).fill(null).map((_, x) => {
|
mapData = Array(this.map_size).fill(null).map((_, y) => Array(this.map_size).fill(null).map((_, x) => {
|
||||||
|
@ -180,24 +181,24 @@ class time {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.year = 812;
|
this.year = 812;
|
||||||
this.month = 1;
|
this.month = 1;
|
||||||
this.day=13;
|
this.day = 13;
|
||||||
this.season='winter';
|
this.season = 'winter';
|
||||||
this.hour=12;
|
this.hour = 12;
|
||||||
this.day=true;
|
this.day = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tick(){
|
tick() {
|
||||||
this.hour=(this.hour+1) % 24
|
this.hour = (this.hour + 1) % 24
|
||||||
if (this.hour==1) this.day=(this.day+1) % 30
|
if (this.hour == 1) this.day = (this.day + 1) % 30
|
||||||
if (this.day==1) {this.month=(this.month+1) % 12;}
|
if (this.day == 1) { this.month = (this.month + 1) % 12; }
|
||||||
if (this.month==1) {this.year=(this.year+1); }
|
if (this.month == 1) { this.year = (this.year + 1); }
|
||||||
if (this.month==6 && this.day==21) {this.season='summer'; }
|
if (this.month == 6 && this.day == 21) { this.season = 'summer'; }
|
||||||
if (this.month==9 && this.day==21) {this.season='autumn'; }
|
if (this.month == 9 && this.day == 21) { this.season = 'autumn'; }
|
||||||
if (this.month==12 && this.day==21) {this.season='winter'; }
|
if (this.month == 12 && this.day == 21) { this.season = 'winter'; }
|
||||||
if (this.month==3 && this.day==21) {this.season='fall'; }
|
if (this.month == 3 && this.day == 21) { this.season = 'fall'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
wait(nbrHour){
|
wait(nbrHour) {
|
||||||
for (let i = 0; i < nbrHour; i++) {
|
for (let i = 0; i < nbrHour; i++) {
|
||||||
this.tick();
|
this.tick();
|
||||||
}
|
}
|
||||||
|
@ -207,12 +208,12 @@ class time {
|
||||||
}
|
}
|
||||||
class attributes {
|
class attributes {
|
||||||
constructor(race) {
|
constructor(race) {
|
||||||
this.strength=race.strength;
|
this.strength = race.strength;
|
||||||
this.vitality=race.vitality;
|
this.vitality = race.vitality;
|
||||||
this.dexterity=race.dexterity;
|
this.dexterity = race.dexterity;
|
||||||
this.intelligence=race.intelligence;
|
this.intelligence = race.intelligence;
|
||||||
this.wisdom=race.wisdom;
|
this.wisdom = race.wisdom;
|
||||||
this.luck=rand();
|
this.luck = rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode de l'objet
|
// Méthode de l'objet
|
||||||
|
@ -220,7 +221,7 @@ class attributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
class creature {
|
class creature {
|
||||||
constructor(name,attributes,level,affinities,name,alignments,position,species,race,hp,items) {
|
constructor(name, attributes, level, affinities, name, alignments, position, species, race, hp, items) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
@ -229,20 +230,20 @@ class creature {
|
||||||
this.alignments = alignments;
|
this.alignments = alignments;
|
||||||
this.species = species;
|
this.species = species;
|
||||||
this.race = race;
|
this.race = race;
|
||||||
this.hp=hp;
|
this.hp = hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fight(){
|
fight() {
|
||||||
|
|
||||||
}
|
}
|
||||||
// Méthode de l'objet
|
// Méthode de l'objet
|
||||||
|
|
||||||
}
|
}
|
||||||
class npc {
|
class npc {
|
||||||
constructor(name,creature,settlement,equipments) {
|
constructor(name, creature, settlement, equipments) {
|
||||||
this.creature=creature;
|
this.creature = creature;
|
||||||
this.settlement=settlement;
|
this.settlement = settlement;
|
||||||
this.equipments=equipments;
|
this.equipments = equipments;
|
||||||
}
|
}
|
||||||
|
|
||||||
talk() {
|
talk() {
|
||||||
|
@ -261,27 +262,27 @@ class npc {
|
||||||
}
|
}
|
||||||
|
|
||||||
class player {
|
class player {
|
||||||
constructor(name,creature,equipments) {
|
constructor(name, creature, equipments) {
|
||||||
this.creature=creature;
|
this.creature = creature;
|
||||||
this.equipments=equipments;
|
this.equipments = equipments;
|
||||||
|
|
||||||
}
|
}
|
||||||
move(position) {
|
move(position) {
|
||||||
this.position=position
|
this.position = position
|
||||||
}
|
}
|
||||||
|
|
||||||
rename(name) {
|
rename(name) {
|
||||||
this.name=name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
equipItem(item,slot) {
|
equipItem(item, slot) {
|
||||||
equipment.equip(item,slot);
|
equipment.equip(item, slot);
|
||||||
updateAttribute();
|
updateAttribute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class settlement {
|
class settlement {
|
||||||
constructor(level,affinities,name,alignments,position,structures) {
|
constructor(level, affinities, name, alignments, position, structures) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.affinities = affinities;
|
this.affinities = affinities;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -293,12 +294,12 @@ class settlement {
|
||||||
|
|
||||||
}
|
}
|
||||||
class resource {
|
class resource {
|
||||||
constructor(resourceType,position) {
|
constructor(resourceType, position) {
|
||||||
this.resourceType = resourceType;
|
this.resourceType = resourceType;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
collect(creature){
|
collect(creature) {
|
||||||
// check if creature can collect
|
// check if creature can collect
|
||||||
// transfer resulting items creature.items[]=this.resourceType.item
|
// transfer resulting items creature.items[]=this.resourceType.item
|
||||||
this = null;//end object
|
this = null;//end object
|
||||||
|
@ -308,7 +309,7 @@ class resource {
|
||||||
}
|
}
|
||||||
class equipment {
|
class equipment {
|
||||||
|
|
||||||
constructor(item,slot) {
|
constructor(item, slot) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +327,7 @@ class equipment {
|
||||||
}
|
}
|
||||||
class soul {
|
class soul {
|
||||||
|
|
||||||
constructor(name,description) {
|
constructor(name, description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
@ -338,13 +339,13 @@ class soul {
|
||||||
}
|
}
|
||||||
class item {
|
class item {
|
||||||
|
|
||||||
constructor(name,duration,itemType) {
|
constructor(name, duration, itemType) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (!Object.values(ItemType).includes(itemType)) {
|
if (!Object.values(ItemType).includes(itemType)) {
|
||||||
throw new Error('Item type invalide !');
|
throw new Error('Item type invalide !');
|
||||||
}
|
}
|
||||||
this.itemType = itemType;
|
this.itemType = itemType;
|
||||||
if (duration){
|
if (duration) {
|
||||||
this.duration = itemType.duration
|
this.duration = itemType.duration
|
||||||
} else {
|
} else {
|
||||||
this.duration = duration
|
this.duration = duration
|
||||||
|
@ -358,9 +359,9 @@ class item {
|
||||||
destroy() {
|
destroy() {
|
||||||
this = null;
|
this = null;
|
||||||
}
|
}
|
||||||
use(){
|
use() {
|
||||||
if (this.duration >1) {
|
if (this.duration > 1) {
|
||||||
this.duration = this.duration-1
|
this.duration = this.duration - 1
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue