-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create PR #25
Open
GitSwaggCat
wants to merge
5
commits into
ISUCT:Novoselov_Nikolaj_Vitalevich
Choose a base branch
from
GitSwaggCat:Novoselov_Nikolaj_Vitalevich
base: Novoselov_Nikolaj_Vitalevich
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Create PR #25
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,32 @@ | ||
import { Player } from '../../Player/player'; | ||
import { Status } from "../../Player/Ability"; | ||
export enum Archer_Shape { | ||
Hunter = 'Hunter', | ||
Raider = 'Raider', | ||
Elemental_Mage = 'Elemental_Mage', | ||
} | ||
|
||
export class Archer extends Player { | ||
_healthpool: number; | ||
_hp: number; | ||
_power: number = 10; | ||
//_hitchance: number = 85; | ||
//_suppress: number = 25; | ||
Shape: Archer_Shape; | ||
constructor(Shape: Archer_Shape, name: string, hp: number) { | ||
super(name); | ||
this.Shape = Shape; | ||
this._hp = hp; | ||
this._healthpool = hp; | ||
} | ||
ability(){ | ||
return ['ability', 7, 3, Status.Ignite] | ||
} | ||
attack() { | ||
return ['damage',this._power]; | ||
} | ||
|
||
public toString(): string { | ||
return "(Archer) " + this._name; | ||
} | ||
} |
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,34 @@ | ||
import { Player } from '../../Player/player'; | ||
import { Status } from "../../Player/Ability"; | ||
export enum Mage_Shape { | ||
Inquisitor = 'Inquisitor', | ||
Forbidden = 'Forbidden', | ||
Occultist = 'Occultist', | ||
} | ||
|
||
export class Mage extends Player { | ||
_healthpool: number; | ||
_hp: number; | ||
_power: number = 12; | ||
//_hitchance:number = 90; | ||
//_evade:number = 10; | ||
Shape: Mage_Shape; | ||
constructor(Shape: Mage_Shape, name: string, hp: number) { | ||
super(name); | ||
this.Shape = Shape; | ||
this._hp = hp; | ||
this._healthpool = hp; | ||
} | ||
|
||
ability(){ | ||
return ['ability', 0, 2, Status.Freeze] | ||
} | ||
|
||
attack() { | ||
return ['damage',this._power]; | ||
} | ||
|
||
public toString(): string { | ||
return "(Mage) " + this._name; | ||
} | ||
} |
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,35 @@ | ||
import { Player } from '../../Player/player'; | ||
import { Status } from "../../Player/Ability"; | ||
export enum Warrior_Shape { | ||
Juggernaut = 'Juggernaut', | ||
Marauder = 'Marauder', | ||
Slayer = 'Slayer', | ||
} | ||
|
||
export class Warrior extends Player { | ||
_healthpool: number; | ||
_hp: number; | ||
_power: number = 8; | ||
//_hitchance:number = 80; | ||
//_block:number = 10; | ||
Shape: Warrior_Shape; | ||
constructor(Shape: Warrior_Shape, name: string, hp: number) { | ||
super(name); | ||
this.Shape = Shape; | ||
this._hp = hp; | ||
this._healthpool = hp; | ||
} | ||
ability(){ | ||
return ['ability', 4, 6, Status.Bleed] | ||
} | ||
|
||
attack() { | ||
return ['damage',this._power]; | ||
} | ||
|
||
public toString(): string { | ||
return "(Warrior) " + this._name; | ||
} | ||
|
||
} | ||
|
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,29 @@ | ||
import { Player } from "../Player/player"; | ||
|
||
export class Logger{ | ||
static WriteWinner(winner: Player){ | ||
console.log() | ||
console.log(`${winner} win this game`) | ||
console.log() | ||
} | ||
static WritebattleNumber(number){ | ||
console.log(`Battle № ${number}`) | ||
} | ||
static WritebattleMembers(battleMembers: Player[]){ | ||
console.log(`${battleMembers[0]} VS ${battleMembers[1]}`); | ||
} | ||
|
||
static WriteDeath(looser: Player): void { | ||
console.log(`${looser} dead`); | ||
} | ||
static WriteAction(firstplayer, secondplayer, MoveAction){ | ||
if (MoveAction[0] == 'damage') { | ||
console.log((`${firstplayer} deal ${MoveAction[1]} damage to enemy ${secondplayer}`)); | ||
}else{ | ||
console.log((`${firstplayer} imposed ${MoveAction[3]} on ${secondplayer}`)); | ||
} | ||
} | ||
static WriteDagameFromAbility(player){ | ||
console.log(`${player} get ${player.CheckStatus()[2]} damage from enemy's ability`) | ||
} | ||
} |
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,6 @@ | ||
export enum Status{ | ||
Ignite = 'Ignite', | ||
Freeze = 'Freeze', | ||
Bleed = 'Bleed', | ||
None = 'None' | ||
} |
19 changes: 19 additions & 0 deletions
19
rpgsaga/saga/src/SagaRPG/Player/Grid-generator/Grid-generator.ts
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,19 @@ | ||
import { Random } from "../../random/randomNum"; | ||
import { generator} from "../Player_generator/Player_generator"; | ||
import { Player } from "../player"; | ||
|
||
//classes | ||
export enum classes { | ||
Archer = 'Archer', | ||
Warrior = 'Warrior', | ||
Mage = 'Mage', | ||
} | ||
const classes_array: Array<classes> = [classes.Archer, classes.Warrior, classes.Mage]; | ||
|
||
export function Grid_generator(player_quantity):Player[]{ | ||
let player_grid:Player[] = [] | ||
for (let index = 0; index < player_quantity; index++) { | ||
player_grid.push(generator(classes_array[Random(0,2)])) | ||
} | ||
return player_grid | ||
} |
28 changes: 28 additions & 0 deletions
28
rpgsaga/saga/src/SagaRPG/Player/Player_generator/Player_generator.ts
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,28 @@ | ||
import { Random } from '../../random/randomNum'; | ||
import { Warrior, Warrior_Shape } from '../../Classes/Warrior/Warrior'; | ||
import { Mage, Mage_Shape } from '../../Classes/Mage/Mage'; | ||
import { Archer, Archer_Shape } from '../../Classes/Archer/Archer'; | ||
import { Player } from '../player'; | ||
import { classes } from '../Grid-generator/Grid-generator'; | ||
//Shape | ||
const A_Shape: Archer_Shape[] = [Archer_Shape.Hunter, Archer_Shape.Raider, Archer_Shape.Elemental_Mage]; | ||
const M_Shape: Mage_Shape[] = [Mage_Shape.Forbidden, Mage_Shape.Inquisitor, Mage_Shape.Occultist]; | ||
const W_Shape: Warrior_Shape[] = [Warrior_Shape.Juggernaut, Warrior_Shape.Marauder, Warrior_Shape.Slayer]; | ||
//names | ||
const names: string[] = ['Sergey', 'Danilla', 'Nikola', 'Artem', 'Denis', 'Karina', 'Evgenia', 'Elena', 'Egor']; | ||
|
||
export function generator(player_class: classes) { | ||
let player: Player; | ||
switch (player_class) { | ||
case classes.Archer: | ||
player = new Archer(A_Shape[Random(0, 2)], names[Random(0, 8)], Random(90, 110)); | ||
break; | ||
case classes.Warrior: | ||
player = new Warrior(W_Shape[Random(0, 2)], names[Random(0, 8)], Random(110, 130)); | ||
break; | ||
default: | ||
player = new Mage(M_Shape[Random(0, 2)], names[Random(0, 8)], Random(70, 90)); | ||
break; | ||
} | ||
return player; | ||
} |
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,46 @@ | ||
import { stat } from "fs"; | ||
import { Status } from "../Player/Ability"; | ||
export class Player { | ||
_hp: number; | ||
_power: number; | ||
_healthpool: number; | ||
_name: string; | ||
_status: [Status, number, number?] = [Status.None, 0, 0]; | ||
//_hitchance: number; | ||
constructor(name: string) { | ||
this._name = name; | ||
} | ||
|
||
ability(){ | ||
return ['ability', 6, 3, Status.Ignite] | ||
} | ||
attack() { | ||
return ['damage',this._power]; | ||
} | ||
DeathOrAlive(): boolean { | ||
if (this._hp <= 0) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
getDamage(damage: number): boolean { | ||
this._hp = this._hp - damage; | ||
return this.DeathOrAlive(); | ||
} | ||
restore():void { | ||
this._hp = this._healthpool; | ||
this._status = [Status.None, 0, 0] | ||
} | ||
|
||
CheckStatus(){ | ||
return this._status | ||
} | ||
getStatus(status){ | ||
this._status = status | ||
} | ||
TakeDamageFromAbility(){ | ||
this._healthpool -= this.CheckStatus[1] | ||
this.CheckStatus[1] - 1 | ||
} | ||
} |
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,67 @@ | ||
import { Player } from '../Player/player'; | ||
import { Grid_generator } from '../Player/Grid-generator/Grid-generator'; | ||
import { Logger } from '../Logger/logger'; | ||
import { Random } from '../random/randomNum'; | ||
import { Status } from '../Player/Ability'; | ||
import { stat } from 'fs'; | ||
export class battle { | ||
static Start(player_quantity): void { | ||
let grid: Player[] = Grid_generator(player_quantity); | ||
battle.Play(grid); | ||
} | ||
static Play(grid: Player[]): void { | ||
let length = grid.length; | ||
for (let index = 1; index < length; index++) { | ||
Logger.WritebattleNumber(index); | ||
battle.Playround(grid, length); | ||
} | ||
Logger.WriteWinner(grid[0]); | ||
} | ||
static Playround(grid: Player[], length): void { | ||
let RoundMembers = [grid[0], grid[1]]; | ||
Logger.WritebattleMembers(RoundMembers); | ||
let winner = battle.Playbattle(RoundMembers); | ||
grid.push(winner); | ||
grid.splice(0, 2); | ||
} | ||
static Playbattle(RoundMembers): Player { | ||
for (let index = 0; true; index++) { | ||
if (RoundMembers[index % 2].CheckStatus()[0] == Status.Freeze && RoundMembers[index % 2].CheckStatus()[1] != 0) { | ||
console.log(`${RoundMembers[index % 2]} skip move`); | ||
RoundMembers[index % 2].CheckStatus()[1] -= 1; | ||
}else { | ||
if (RoundMembers[index % 2].CheckStatus()[0] == Status.Ignite || RoundMembers[index % 2].CheckStatus()[0] == Status.Bleed && RoundMembers[index % 2].CheckStatus()[1] < 0) { | ||
|
||
RoundMembers[index%2].TakeDamageFromAbility() | ||
Logger.WriteDagameFromAbility(RoundMembers[index%2]) | ||
} | ||
let PlayerMode = RoundMembers[index % 2].DeathOrAlive(); | ||
if (PlayerMode) { | ||
return RoundMembers[(index + 1) % 2]; | ||
} | ||
let MoveAction = battle.PlayerAction(RoundMembers[index % 2]); | ||
if (MoveAction[0] == 'damage') { | ||
PlayerMode = RoundMembers[(index + 1) % 2].getDamage(MoveAction[1]); | ||
Logger.WriteAction(RoundMembers[index % 2], RoundMembers[(index + 1) % 2], MoveAction); | ||
} else { | ||
RoundMembers[(index + 1) % 2].getStatus([MoveAction[3], MoveAction[2], MoveAction[1]]); | ||
Logger.WriteAction(RoundMembers[index % 2], RoundMembers[(index + 1) % 2], MoveAction); | ||
} | ||
if (PlayerMode) { | ||
Logger.WriteDeath(RoundMembers[(index + 1) % 2]); | ||
RoundMembers[index % 2].restore(); | ||
return RoundMembers[index % 2]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
static PlayerAction(player): void { | ||
let chance = Random(0, 10); | ||
if (chance <= 1) { | ||
return player.ability(); | ||
} else { | ||
return player.attack(); | ||
} | ||
} | ||
} |
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,3 @@ | ||
export function Random(min: number, max: number): number{ | ||
return Math.round(Math.random() * (max - min) + min); | ||
} |
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,42 @@ | ||
export enum Mode { | ||
ALIVE = "Alive", | ||
DIED = "Died" | ||
} | ||
export class Mouse { | ||
_healthpool: number = 100; | ||
private _age: number; | ||
_color: string; | ||
_mode: Mode = Mode.ALIVE; | ||
constructor(year: number, color: string) { | ||
this.year = year; | ||
this._color = color; | ||
}; | ||
set year(year: number) { | ||
this._age = year > 0 && year < 4 ? year : 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. при неправильном значении бросайте exception |
||
} | ||
get year(): number { | ||
return this._age | ||
} | ||
hit(): string { | ||
this._healthpool -= 10 | ||
if (this._healthpool > 0) { | ||
return `Вы ударили мышь, теперь у неё ${this._healthpool} здоровья` | ||
} else { | ||
this._mode = Mode.DIED | ||
return "Мышь сдохла" | ||
} | ||
} | ||
heal(): string { | ||
this._healthpool = 100 | ||
return `Теперь здоровье мыши в норме и составляет 100 единиц` | ||
} | ||
paint(color): string { | ||
if (this._color == color) { | ||
return `Зачем вы красите ${this._color} в ${color}` | ||
} else { | ||
this._color = color | ||
return `Теперь мышь имеет ${color} цвет` | ||
} | ||
} | ||
|
||
} |
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,16 +1,3 @@ | ||
import { Phone } from './phone'; | ||
|
||
const first = new Phone('+7900-000 000 (123)', 1990, 'Телефон 1'); | ||
first.year = 1998; | ||
|
||
first.year = -1998; | ||
first.call('12345'); | ||
first.endCall(); | ||
|
||
const second = new Phone('+799900000', -5); | ||
// second.name = 'Телефон 2'; | ||
console.log(second.year); | ||
second.call('12345'); | ||
second.endCall(); | ||
|
||
console.log(first, second, Phone.phoneCount); | ||
import { Grid_generator } from "./SagaRPG/Player/Grid-generator/Grid-generator"; | ||
import { battle } from "./SagaRPG/battle/battle"; | ||
console.log(battle.Start(2)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и извне могу ее убить - поле то публичное