Skip to content

Commit

Permalink
feat(Modules): ✨ add NullModules
Browse files Browse the repository at this point in the history
  • Loading branch information
asdawej committed Nov 1, 2023
1 parent b4cc258 commit b181e0f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 18 deletions.
36 changes: 18 additions & 18 deletions logic/GameClass/GameObj/Modules/ModuleFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public static class ModuleFactory
ProducerType.Producer1 => new CivilProducer1(),
ProducerType.Producer2 => new CivilProducer2(),
ProducerType.Producer3 => new CivilProducer3(),
_ => throw new System.NotImplementedException()
_ => new NullProducer()
},
ShipType.FlagShip => producerType switch
{
ProducerType.Producer1 => new FlagProducer1(),
_ => throw new System.NotImplementedException()
_ => new NullProducer()
},
_ => throw new System.NotImplementedException()
_ => new NullProducer()
};
public static IConstructor FindIConstructor(ShipType shipType, ConstructorType constructorType) => shipType switch
{
Expand All @@ -28,67 +28,67 @@ public static class ModuleFactory
ConstructorType.Constructor1 => new CivilConstructor1(),
ConstructorType.Constructor2 => new CivilConstructor2(),
ConstructorType.Constructor3 => new CivilConstructor3(),
_ => throw new System.NotImplementedException()
_ => new NullConstructor()
},
ShipType.FlagShip => constructorType switch
{
ConstructorType.Constructor1 => new FlagConstructor1(),
_ => throw new System.NotImplementedException()
_ => new NullConstructor()
},
_ => throw new System.NotImplementedException()
_ => new NullConstructor()
};
public static IArmor FindIArmor(ShipType shipType, ArmorType armorType) => shipType switch
{
ShipType.CivilShip => armorType switch
{
ArmorType.Armor1 => new CivilArmor1(),
_ => throw new System.NotImplementedException()
_ => new NullArmor()
},
ShipType.WarShip => armorType switch
{
ArmorType.Armor1 => new WarArmor1(),
ArmorType.Armor2 => new WarArmor2(),
ArmorType.Armor3 => new WarArmor3(),
_ => throw new System.NotImplementedException()
_ => new NullArmor()
},
ShipType.FlagShip => armorType switch
{
ArmorType.Armor1 => new FlagArmor1(),
ArmorType.Armor2 => new FlagArmor2(),
ArmorType.Armor3 => new FlagArmor3(),
_ => throw new System.NotImplementedException()
_ => new NullArmor()
},
_ => throw new System.NotImplementedException()
_ => new NullArmor()
};
public static IShield FindIShield(ShipType shipType, ShieldType shieldType) => shipType switch
{
ShipType.CivilShip => shieldType switch
{
ShieldType.Shield1 => new CivilShield1(),
_ => throw new System.NotImplementedException()
_ => new NullShield()
},
ShipType.WarShip => shieldType switch
{
ShieldType.Shield1 => new WarShield1(),
ShieldType.Shield2 => new WarShield2(),
ShieldType.Shield3 => new WarShield3(),
_ => throw new System.NotImplementedException()
_ => new NullShield()
},
ShipType.FlagShip => shieldType switch
{
ShieldType.Shield1 => new FlagShield1(),
ShieldType.Shield2 => new FlagShield2(),
ShieldType.Shield3 => new FlagShield3(),
_ => throw new System.NotImplementedException()
_ => new NullShield()
},
_ => throw new System.NotImplementedException()
_ => new NullShield()
};
public static IWeapon FindIWeapon(ShipType shipType, WeaponType weaponType) => shipType switch
{
ShipType.CivilShip => weaponType switch
{
WeaponType.LaserGun => new CivilLaserGun(),
_ => throw new System.NotImplementedException()
_ => new NullWeapon()
},
ShipType.WarShip => weaponType switch
{
Expand All @@ -97,7 +97,7 @@ public static class ModuleFactory
WeaponType.ShellGun => new WarShellGun(),
WeaponType.MissileGun => new WarMissileGun(),
WeaponType.ArcGun => new WarArcGun(),
_ => throw new System.NotImplementedException()
_ => new NullWeapon()
},
ShipType.FlagShip => weaponType switch
{
Expand All @@ -106,8 +106,8 @@ public static class ModuleFactory
WeaponType.ShellGun => new FlagShellGun(),
WeaponType.MissileGun => new FlagMissileGun(),
WeaponType.ArcGun => new FlagArcGun(),
_ => throw new System.NotImplementedException()
_ => new NullWeapon()
},
_ => throw new System.NotImplementedException()
_ => new NullWeapon()
};
}
9 changes: 9 additions & 0 deletions logic/GameClass/GameObj/Modules/NullModules/NullArmor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Preparation.Interface;

namespace GameClass.GameObj.Modules;

public class NullArmor : IArmor
{
public int ArmorHP => 0;
public int Cost => 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Preparation.Interface;

namespace GameClass.GameObj.Modules;

public class NullConstructor : IConstructor
{
public int ConstructSpeed => 0;
public int Cost => 0;
}
9 changes: 9 additions & 0 deletions logic/GameClass/GameObj/Modules/NullModules/NullProducer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Preparation.Interface;

namespace GameClass.GameObj.Modules;

public class NullProducer : IProducer
{
public int ProduceSpeed => 0;
public int Cost => 0;
}
9 changes: 9 additions & 0 deletions logic/GameClass/GameObj/Modules/NullModules/NullShield.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Preparation.Interface;

namespace GameClass.GameObj.Modules;

public class NullShield : IShield
{
public int ShieldHP => 0;
public int Cost => 0;
}
10 changes: 10 additions & 0 deletions logic/GameClass/GameObj/Modules/NullModules/NullWeapon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Preparation.Interface;
using Preparation.Utility;

namespace GameClass.GameObj.Modules;

public class NullWeapon : IWeapon
{
public BulletType BulletType => BulletType.Null;
public int Cost => 0;
}

0 comments on commit b181e0f

Please sign in to comment.