Skip to content

Commit

Permalink
Merge pull request TK11235#8 from h-mikisato/feature/clone_seq
Browse files Browse the repository at this point in the history
キャラクターをコピーした際に番号を付与する
  • Loading branch information
entyu authored Feb 26, 2021
2 parents 73bc39f + 18c0d4f commit 0aab0a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/app/class/game-character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export class GameCharacter extends TabletopObject {
}
return null;
}


set name(value:string) { this.setCommonValue('name', value); }

TestExec() {
console.log('TestExec');

Expand Down Expand Up @@ -107,6 +109,27 @@ export class GameCharacter extends TabletopObject {
}
}

clone() :this {
let cloneObject = super.clone();

let objectname:string;
let reg = new RegExp('^(.*)_([0-9]+)$');
let res = cloneObject.name.match(reg);

if(res != null && res.length == 3) {
let cloneNumber:number = parseInt(res[2]) + 1;
objectname = res[1] + "_" + cloneNumber;
} else {
objectname = cloneObject.name + "_2";
}

cloneObject.name = objectname;
cloneObject.update();

return cloneObject;

}

createTestGameDataElement(name: string, size: number, imageIdentifier: string) {
this.createDataElements();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,4 @@ export class GameCharacterComponent implements OnInit, OnDestroy, AfterViewInit
let component = this.panelService.open<RemoteControllerComponent>(RemoteControllerComponent, option);
component.character = gameObject;
}

}

0 comments on commit 0aab0a5

Please sign in to comment.