Skip to content

Commit

Permalink
ウェルロッドMk.1を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-arataki committed Apr 8, 2019
1 parent 03f272d commit 44b8190
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 9 deletions.
16 changes: 10 additions & 6 deletions src/App/Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@ export const GunFactory: Factory = {
{title: "Glock17", value: "glock17"},
{title: "Glock17L(ロングバレル)", value: "glock17l"},
{title: "ベレッタM92F", value: "m92f"},
{title: ".44オートマグ", value: "automag"}
{title: ".44オートマグ", value: "automag"},
{title: "ウェルロッドMk.1(ボルトアクション・消音)", value: "welrod1"}
]
},
glock17: (): g.Gun => new g.GunGlock17,
glock17l: (): g.Gun => new g.GunGlock17L,
m92f: (): g.Gun => new g.GunM92F,
automag: (): g.Gun => new g.Gun44AutoMag
automag: (): g.Gun => new g.Gun44AutoMag,
welrod1: (): g.Gun => new g.GunWelrodMk1
};

export const MagazineFactory: Factory = {
choices() {
return [
{title: "Glock17用", value: "glock17"},
{title: "ベレッタM92F用", value: "m92f"},
{title: ".44オートマグ用", value: "automag"}
{title: "Glock17用(9mm)", value: "glock17"},
{title: "ベレッタM92F用(9mm)", value: "m92f"},
{title: ".44オートマグ用(.44口径)", value: "automag"},
{title: "ウェルロッドMk.1用(9mm)", value: "welrod1"}
]
},
glock17: ():m.Magazine => new m.MagazineGlockStandard,
m92f: (): m.Magazine => new m.MagazineM92,
automag: (): m.Magazine => new m.Magazine44AutoMag
automag: (): m.Magazine => new m.Magazine44AutoMag,
welrod1: (): m.Magazine => new m.MagazineWelrodMk1
};

export const BulletFactory: Factory = {
Expand Down
2 changes: 1 addition & 1 deletion src/App/Gun/Gun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default abstract class Gun
{
protected abstract name: string

protected semiAuto: boolean = false
protected semiAuto: boolean = true

public magroom: m.Magazine | null = null

Expand Down
32 changes: 32 additions & 0 deletions src/App/Gun/GunWelrodMk1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Gun from './Gun'
import * as m from '../Magazine'
import * as b from '../Bullet'
import event from '../Event'

export default class GunWelrodMk1 extends Gun
{
protected name: string = 'ウェルロッドMk.1';
protected semiAuto: boolean = false

setMagazine(magazine: m.Magazine): boolean {
if (magazine instanceof m.MagazineWelrodMk1) {
return super.setMagazine(magazine)
}

event.emit('Gun.SetMagazine.Error.Compatibility', { gun: this, magazine: magazine })
return false;
}

setBullet(bullet: b.Bullet | undefined = undefined): boolean {
if (bullet instanceof b.Bullet9mm || bullet === undefined) {
return super.setBullet(bullet)
}

event.emit('Gun.SetBullet.Error.Compatibility', { gun: this, bullet: bullet })
return false;
}

shotSound(bullet: b.Bullet): string {
return '< プシュッ >'
}
}
4 changes: 3 additions & 1 deletion src/App/Gun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import GunGlock17 from './GunGlock17'
import GunGlock17L from './GunGlock17L'
import GunM92F from './GunM92F'
import Gun44AutoMag from './Gun44AutoMag'
import GunWelrodMk1 from './GunWelrodMk1'

export {
Gun,
GunGlock17,
GunGlock17L,
GunM92F,
Gun44AutoMag
Gun44AutoMag,
GunWelrodMk1
};
18 changes: 18 additions & 0 deletions src/App/Magazine/MagazineWelrodMk1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Magazine from './Magazine'
import * as b from '../Bullet'
import event from '../Event'

export default class MagazineWelrodMk1 extends Magazine
{
protected name: string = 'ウェルロッドMk1マガジン';
protected max: number = 5;

pushBullet(bullet: b.Bullet): boolean {
if (bullet instanceof b.Bullet9mm) {
return super.pushBullet(bullet)
}

event.emit('Magazine.PushBullet.Error.Compatibility', { magazine: this, bullet: bullet })
return false;
}
}
4 changes: 3 additions & 1 deletion src/App/Magazine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import Magazine from './Magazine'
import MagazineGlockStandard from './MagazineGlockStandard'
import MagazineM92 from './MagazineM92'
import Magazine44AutoMag from './Magazine44AutoMag'
import MagazineWelrodMk1 from './MagazineWelrodMk1'

export {
Magazine,
MagazineGlockStandard,
MagazineM92,
Magazine44AutoMag
Magazine44AutoMag,
MagazineWelrodMk1
};

0 comments on commit 44b8190

Please sign in to comment.