This repository has been archived by the owner on Jun 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a classes to save player's data on the server.
for #2
- Loading branch information
Showing
9 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Part } from './Part'; | ||
|
||
export class BodyParts { | ||
public head : Part; | ||
public torso : Part; | ||
public legs : Part; | ||
|
||
constructor(public characterName: string) { | ||
this.head = new Part(characterName, 'Head'); | ||
this.torso = new Part(characterName, 'Torso'); | ||
this.legs = new Part(characterName, 'Legs'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as data from '../../database/Essences.json'; | ||
|
||
export class Essence { | ||
public static getEssence(key : string) : number { | ||
return data.Essence[key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { StatsAdditions } from './StatsAdditions'; | ||
import { StatsConverter } from './StatsConverter'; | ||
|
||
export class Part{ | ||
public stats: StatsAdditions; | ||
|
||
constructor(public characterName: string, public part : string) { | ||
this.stats = StatsConverter.getStats(characterName, part); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
import { Position } from './Position'; | ||
import { PlayerCharactiristics } from './PlayerCharactiristics'; | ||
import { BodyParts } from './BodyParts'; | ||
import { Essence } from './Essence'; | ||
|
||
export class Player { | ||
private static playerCounter: number; | ||
|
||
public name: string; | ||
public score : number; | ||
public currentKarma: number; | ||
public currentHealth: number; | ||
public currentHealthRegeneration: number; | ||
public currentDamage: number; | ||
public currentMovementSpeed: number; | ||
public currentArmor: number; | ||
public essence: number; | ||
public bodyParts: BodyParts; | ||
public charactirisrics: PlayerCharactiristics; | ||
|
||
constructor( | ||
public position: Position = new Position(), | ||
public rotation = 0, | ||
) { | ||
this.name = `player${Player.playerCounter}`; | ||
public name: string = `player${Player.playerCounter}`, | ||
public team: string = 'team ' + `player${Player.playerCounter}`) { | ||
Player.playerCounter += 1; | ||
this.score = 0; | ||
this.currentHealth = 100; | ||
this.charactirisrics = new PlayerCharactiristics(); | ||
this.bodyParts = new BodyParts('Human'); | ||
this.currentKarma = this.charactirisrics.basicKarma; | ||
this.currentHealthRegeneration = this.charactirisrics.basicHealthRegeneration; | ||
this.currentDamage = this.charactirisrics.basicDamage; | ||
this.currentMovementSpeed = this.charactirisrics.basicMovementSpeed; | ||
this.currentArmor = this.charactirisrics.basicArmor; | ||
this.essence = Essence.getEssence('NEAUTRAL'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export class PlayerCharactiristics{ | ||
constructor(public basicKarma : number = 0, | ||
public basicHealthRegeneration : number = 0.5, | ||
public basicDamage : number = 10, | ||
public basicMovementSpeed : number = 25, | ||
public basicArmor : number = 0, | ||
public maxMovementSpeed: number = 250, | ||
public maxArmor: number = 100, | ||
public maxKarma: number = 150) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Essence } from './Essence'; | ||
|
||
export class StatsAdditions { | ||
constructor(public health : number = 0, | ||
public healthRegeneration: number = 0, | ||
public armor : number = 0, | ||
public baseDamage: number = 0, | ||
public karma : number = 0, | ||
public movementSpeed : number = 0) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as data from '../../database/Characters.json'; | ||
import { StatsAdditions } from './StatsAdditions'; | ||
|
||
export class StatsConverter { | ||
public static getStats (name : string = 'Human', part : string) : StatsAdditions { | ||
const databasePart = data[name][part]; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
const health = StatsConverter.filterState(databasePart['HP']); | ||
const healthRegeneration = StatsConverter.filterState(databasePart['HRP']); | ||
const armor = StatsConverter.filterState(databasePart['AR']); | ||
const baseDamage = StatsConverter.filterState(databasePart['BD']); | ||
const karma = StatsConverter.filterState(databasePart['CK']); | ||
const movementSpeed = StatsConverter.filterState(databasePart['MS']); | ||
return new StatsAdditions(health, healthRegeneration, armor, | ||
baseDamage, karma, movementSpeed); | ||
} | ||
|
||
private static filterState(state : any) : number { | ||
if (state === 'undefined') { | ||
return 0; | ||
} | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Essence": { | ||
"NEUTRAL": 0, | ||
"GOOD": 1, | ||
"BENEVOLENT": 2, | ||
"RIGHTEOUS": 3, | ||
"DIVINE": 4, | ||
"EVIL": -1, | ||
"MALICIOUS": -2, | ||
"NEFARIOUS": -3, | ||
"SINISTER": -4 | ||
} | ||
} |
data[name][part]["Stats"]