├── UnityPackage
├── SlimeBattleSystem.asmdef
├── Libs
│ ├── SlimeBattleSystem.dll
│ └── SlimeBattleSystem.dll.meta
├── package.json.meta
├── Libs.meta
├── SlimeBattleSystem.asmdef.meta
└── package.json
├── .github
├── FUNDING.yml
└── workflows
│ ├── test.yml
│ └── release.workflow.yml
├── .gitignore
├── Makefile
├── SlimeBattleSystem
├── SlimeBattleSystem.csproj
├── Participant.cs
├── Stats.cs
└── BattleSystem.cs
├── SlimeBattleSystem.Tests
├── SlimeBattleSystem.Tests.csproj
├── RandomMock.cs
└── BattleSystemTests.cs
├── SlimeBattleSystem.sln.DotSettings.user
├── LICENSE
├── SlimeBattleSystem.sln
└── README.md
/UnityPackage/SlimeBattleSystem.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "SlimeBattleSystemPackage"
3 | }
4 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | ko_fi: stumpheadgames
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | /packages/
4 | riderModule.iml
5 | /_ReSharper.Caches/
6 | .idea/
7 | **/.DS_Store
--------------------------------------------------------------------------------
/UnityPackage/Libs/SlimeBattleSystem.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Joshalexjacobs/SlimeBattleSystem/HEAD/UnityPackage/Libs/SlimeBattleSystem.dll
--------------------------------------------------------------------------------
/UnityPackage/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c41bc4cae83fb4b1793c211fd298b489
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/UnityPackage/Libs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d7887752d929244d885e0b30a51383dd
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/UnityPackage/SlimeBattleSystem.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 869249e39d32a4358ba860b375b2c175
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | build:
2 | dotnet build SlimeBattleSystem/*.csproj --configuration Debug
3 |
4 | release:
5 | dotnet build SlimeBattleSystem/*.csproj --configuration Release
6 |
7 | test:
8 | dotnet test SlimeBattleSystem.Tests/*.csproj
9 |
10 | clean:
11 | git clean -xdf
12 |
--------------------------------------------------------------------------------
/UnityPackage/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.joshalexjacobs.slimebattlesystem",
3 | "displayName": "SlimeBattleSystem",
4 | "version": "1.0.0",
5 | "unity": "2021.3",
6 | "description": "An easy to use RPG combat system for Unity that utilizes formulas from the original Dragon Quest games"
7 | }
8 |
--------------------------------------------------------------------------------
/SlimeBattleSystem/SlimeBattleSystem.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 |
3 | on:
4 | push:
5 | pull_request:
6 | branches: [ main ]
7 | paths:
8 | - '**.cs'
9 | - '**.csproj'
10 |
11 | env:
12 | DOTNET_VERSION: '6.0'
13 |
14 | jobs:
15 | tests:
16 | runs-on: ubuntu-latest
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 |
21 | - name: Setup .NET Core
22 | uses: actions/setup-dotnet@v1
23 | with:
24 | dotnet-version: ${{ env.DOTNET_VERSION }}
25 |
26 | - name: Install dependencies
27 | run: dotnet restore
28 |
29 | - name: Test
30 | run: dotnet test --no-restore --verbosity normal
31 |
--------------------------------------------------------------------------------
/SlimeBattleSystem.Tests/SlimeBattleSystem.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SlimeBattleSystem.sln.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from BattleSystemTests.cs" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
3 | <ProjectFile>CE4C4A23-930B-40CE-B6FC-246735A0769D/f:BattleSystemTests.cs</ProjectFile>
4 | </SessionState>
--------------------------------------------------------------------------------
/UnityPackage/Libs/SlimeBattleSystem.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 21364c42edadf47578e5b12e0f0a0e95
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | defineConstraints: []
9 | isPreloaded: 0
10 | isOverridable: 1
11 | isExplicitlyReferenced: 0
12 | validateReferences: 1
13 | platformData:
14 | - first:
15 | Any:
16 | second:
17 | enabled: 1
18 | settings: {}
19 | - first:
20 | Editor: Editor
21 | second:
22 | enabled: 0
23 | settings:
24 | DefaultValueInitialized: true
25 | - first:
26 | Windows Store Apps: WindowsStoreApps
27 | second:
28 | enabled: 0
29 | settings:
30 | CPU: AnyCPU
31 | userData:
32 | assetBundleName:
33 | assetBundleVariant:
34 |
--------------------------------------------------------------------------------
/SlimeBattleSystem.Tests/RandomMock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace SlimeBattleSystem.Tests;
6 |
7 | ///
8 | /// Overrides the Random class. Allows the user to pre-determine which values will be returned from any of the Next()
9 | /// functions.
10 | ///
11 | public class RandomMock : Random {
12 | private readonly List _valueStack;
13 |
14 | public RandomMock(int[] values) {
15 | _valueStack = values.ToList();
16 | }
17 |
18 | ///
19 | /// Pops the next value from the stack of integers provided in the constructor.
20 | ///
21 | /// int
22 | public override int Next() {
23 | var item = _valueStack[_valueStack.Count - 1];
24 |
25 | _valueStack.RemoveAt(_valueStack.Count - 1);
26 |
27 | return item;
28 | }
29 |
30 | public override int Next(int maxValue) {
31 | return Next();
32 | }
33 |
34 | public override int Next(int minValue, int maxValue) {
35 | return Next();
36 | }
37 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Josh Jacobs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/release.workflow.yml:
--------------------------------------------------------------------------------
1 | name: release
2 |
3 | on:
4 | push:
5 | pull_request:
6 | branches: [ main ]
7 | paths:
8 | - '**.cs'
9 | - '**.csproj'
10 |
11 | env:
12 | DOTNET_VERSION: '6.0'
13 |
14 | jobs:
15 | tests:
16 | runs-on: ubuntu-latest
17 |
18 | steps:
19 | - uses: actions/checkout@v3
20 |
21 | - name: Setup .NET Core
22 | uses: actions/setup-dotnet@v2
23 | with:
24 | dotnet-version: ${{ env.DOTNET_VERSION }}
25 |
26 | - name: Install dependencies
27 | run: dotnet restore
28 |
29 | - name: Build
30 | run: dotnet build SlimeBattleSystem/*.csproj --configuration Release
31 |
32 | - name: Release
33 | run: |
34 | yes | cp -r SlimeBattleSystem/bin/Release/netstandard2.0/SlimeBattleSystem.dll UnityPackage/Libs/
35 |
36 | - name: Setup git
37 | run: |
38 | git config user.name "joshalexjacobs-bot"
39 | git config user.email "<>"
40 |
41 | - name: Git commit changes
42 | run: |
43 | git add UnityPackage/Libs/
44 | git commit -m "Updated SlimeBattleSystem.dll [skip ci]" || exit 0
45 | git push origin main
46 |
47 | - name: Git push subtree
48 | run: |
49 | git push origin `git subtree split --prefix UnityPackage main`:upm --force
50 |
--------------------------------------------------------------------------------
/SlimeBattleSystem.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlimeBattleSystem", "SlimeBattleSystem\SlimeBattleSystem.csproj", "{DA2A72E6-17ED-4DF2-9A9B-FB7AD08647C5}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlimeBattleSystem.Tests", "SlimeBattleSystem.Tests\SlimeBattleSystem.Tests.csproj", "{CE4C4A23-930B-40CE-B6FC-246735A0769D}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Any CPU = Debug|Any CPU
10 | Release|Any CPU = Release|Any CPU
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {DA2A72E6-17ED-4DF2-9A9B-FB7AD08647C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14 | {DA2A72E6-17ED-4DF2-9A9B-FB7AD08647C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
15 | {DA2A72E6-17ED-4DF2-9A9B-FB7AD08647C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 | {DA2A72E6-17ED-4DF2-9A9B-FB7AD08647C5}.Release|Any CPU.Build.0 = Release|Any CPU
17 | {CE4C4A23-930B-40CE-B6FC-246735A0769D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {CE4C4A23-930B-40CE-B6FC-246735A0769D}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {CE4C4A23-930B-40CE-B6FC-246735A0769D}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {CE4C4A23-930B-40CE-B6FC-246735A0769D}.Release|Any CPU.Build.0 = Release|Any CPU
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/SlimeBattleSystem/Participant.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SlimeBattleSystem {
4 | [Serializable]
5 | public enum ParticipantType {
6 | Player,
7 | Npc,
8 | Enemy
9 | }
10 |
11 | ///
12 | /// An enemy, NPC, or player character that participates in battle.
13 | ///
14 | [Serializable]
15 | public class Participant {
16 | public int ExperiencePoints;
17 |
18 | public int GoldPoints;
19 |
20 | public string Name;
21 |
22 | public ParticipantType ParticipantType = ParticipantType.Enemy;
23 |
24 | public Stats Stats;
25 |
26 | public int TurnOrder;
27 |
28 | public Participant() {
29 | Stats = new Stats();
30 | }
31 |
32 | public Participant(string name) {
33 | Name = name;
34 |
35 | Stats = new Stats();
36 | }
37 |
38 | public Participant(string name, Stats stats) {
39 | Name = name;
40 |
41 | Stats = stats;
42 | }
43 |
44 | ///
45 | /// Recalculates participants attack power. Should occur after a new weapon is equipped.
46 | ///
47 | /// The attack power stat of the newly equipped weapon.
48 | /// void
49 | public void CalculateAttackPower(int weaponAttackPower) {
50 | Stats.AttackPower = Stats.Strength + weaponAttackPower;
51 | }
52 |
53 | ///
54 | /// Recalculates participants defense power. Should occur after a new piece of armor is equipped.
55 | ///
56 | /// The defense power stat of the newly equipped piece of armor.
57 | /// void
58 | public void CalculateDefensePower(int armorDefensePower) {
59 | Stats.DefensePower = Stats.Agility + armorDefensePower;
60 | }
61 |
62 | ///
63 | /// Inflicts allotted damage to the participant. Will floor hit points to 0.
64 | ///
65 | /// Amount of damage inflicted.
66 | /// void
67 | public void InflictDamage(int damage) {
68 | Stats.HitPoints -= damage;
69 |
70 | if (Stats.HitPoints < 0) Stats.HitPoints = 0;
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/SlimeBattleSystem/Stats.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SlimeBattleSystem {
4 | ///
5 | /// Stats used to track HP, MP, Strength, Agility, Attack Power, Defense Power, and chance to Dodge (X/64).
6 | ///
7 | [Serializable]
8 | public class Stats {
9 | // player's unmodified strength
10 | public int Strength;
11 |
12 | // player's unmodified agility
13 | public int Agility;
14 |
15 | // current HP
16 | public int HitPoints;
17 |
18 | // max HP
19 | public int MaxHitPoints;
20 |
21 | // current MP
22 | public int MagicPoints;
23 |
24 | // max MP
25 | public int MaxMagicPoints;
26 |
27 | // weapons/items that contribute to attack
28 | public int AttackPower;
29 |
30 | // armor/items that contribute to defense
31 | public int DefensePower;
32 |
33 | // chance that a participant can dodge an attack out of 64
34 | public int Dodge;
35 |
36 | // current level
37 | public int Level;
38 |
39 | public Stats() {
40 | HitPoints = 1;
41 |
42 | MaxHitPoints = 1;
43 |
44 | MagicPoints = 1;
45 |
46 | MaxMagicPoints = 1;
47 |
48 | Strength = 1;
49 |
50 | Agility = 1;
51 |
52 | AttackPower = 1;
53 |
54 | DefensePower = 1;
55 |
56 | Dodge = 1;
57 |
58 | Level = 1;
59 | }
60 |
61 | public Stats(Stats stats) {
62 | HitPoints = stats.HitPoints;
63 |
64 | MaxHitPoints = stats.MaxHitPoints;
65 |
66 | MagicPoints = stats.MagicPoints;
67 |
68 | MaxMagicPoints = stats.MaxMagicPoints;
69 |
70 | Strength = stats.Strength;
71 |
72 | Agility = stats.Agility;
73 |
74 | AttackPower = stats.AttackPower;
75 |
76 | DefensePower = stats.DefensePower;
77 |
78 | Dodge = stats.Dodge;
79 |
80 | Level = stats.Level;
81 | }
82 |
83 | public Stats(int hitPoints, int maxHitPoints, int magicPoints, int maxMagicPoints, int strength, int agility,
84 | int attackPower, int defensePower, int dodge, int level = 1) {
85 | HitPoints = hitPoints;
86 |
87 | MaxHitPoints = maxHitPoints;
88 |
89 | MagicPoints = magicPoints;
90 |
91 | MaxMagicPoints = maxMagicPoints;
92 |
93 | Strength = strength;
94 |
95 | Agility = agility;
96 |
97 | AttackPower = attackPower;
98 |
99 | DefensePower = defensePower;
100 |
101 | Dodge = dodge;
102 |
103 | Level = level;
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/SlimeBattleSystem.Tests/BattleSystemTests.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using NUnit.Framework;
3 |
4 | namespace SlimeBattleSystem.Tests;
5 |
6 | public class BattleSystemTests {
7 | [Test]
8 | public void SetRandomizationSeed() {
9 | var seed = "New Seed";
10 |
11 | BattleSystem.SetRandomizationSeed(seed);
12 |
13 | Assert.AreEqual(seed.GetHashCode(), BattleSystem.Seed);
14 | }
15 |
16 | [Test]
17 | public void CalculateTurnOrder() {
18 | var calculatedTurnOrder = BattleSystem.CalculateTurnOrder(9, new RandomMock(new[] { 150 }));
19 |
20 | Assert.AreEqual(5, calculatedTurnOrder);
21 | }
22 |
23 | [Test]
24 | public void DetermineTurnOrder() {
25 | var participantA = new Participant("Participant A");
26 |
27 | participantA.Stats.Agility = 7;
28 |
29 | var participantB = new Participant("Participant B");
30 |
31 | participantB.Stats.Agility = 11;
32 |
33 | var participantC = new Participant("Participant C");
34 |
35 | participantC.Stats.Agility = 4;
36 |
37 | var participants = new List { participantA, participantB, participantC };
38 |
39 | var orderedParticipants = BattleSystem.DetermineTurnOrder(participants, new RandomMock(new[] { 25, 150, 90 }));
40 |
41 | Assert.AreEqual(3, orderedParticipants.Count);
42 |
43 | Assert.AreEqual(participantB.Name, orderedParticipants[0].Name);
44 |
45 | Assert.AreEqual(participantA.Name, orderedParticipants[1].Name);
46 |
47 | Assert.AreEqual(participantC.Name, orderedParticipants[2].Name);
48 | }
49 |
50 | [Test]
51 | public void DetermineEnemyTarget() {
52 | var participantA = new Participant("Participant A");
53 |
54 | participantA.Stats.Agility = 7;
55 |
56 | var participantB = new Participant("Participant B");
57 |
58 | participantB.Stats.Agility = 11;
59 |
60 | var participants = new List { participantA, participantB };
61 |
62 | var target = BattleSystem.DetermineEnemyTarget(participants, new RandomMock(new[] { 1 }));
63 |
64 | Assert.AreEqual(participantB, target);
65 | }
66 |
67 | [Test]
68 | public void DetermineParticipantFleeing() {
69 | var participantA = new Participant("Participant A",
70 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
71 |
72 | var participantB = new Participant("Participant B",
73 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
74 |
75 | Assert.IsTrue(
76 | BattleSystem.DetermineParticipantFleeing(participantA, participantB, new RandomMock(new[] { 0, 3 })));
77 |
78 | Assert.IsFalse(
79 | BattleSystem.DetermineParticipantFleeing(participantA, participantB, new RandomMock(new[] { 255, 1 })));
80 | }
81 |
82 | [Test]
83 | public void GetPlayerParticipants() {
84 | var participantA = new Participant("Participant A",
85 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
86 |
87 | var participantB = new Participant("Participant B",
88 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
89 |
90 | participantB.ParticipantType = ParticipantType.Player;
91 |
92 | var participantC = new Participant("Participant C",
93 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
94 |
95 | Assert.AreEqual(participantB,
96 | BattleSystem.GetPlayerParticipants(new List { participantA, participantB, participantC })[0]);
97 | }
98 |
99 | [Test]
100 | public void GetEnemyParticipants() {
101 | var participantA = new Participant("Participant A",
102 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
103 |
104 | var participantB = new Participant("Participant B",
105 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
106 |
107 | participantB.ParticipantType = ParticipantType.Player;
108 |
109 | var participantC = new Participant("Participant C",
110 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
111 |
112 | var participants = new List { participantA, participantB, participantC };
113 |
114 | var enemyParticipants = BattleSystem.GetEnemyParticipants(participants);
115 |
116 | Assert.AreEqual(participantA, enemyParticipants[0]);
117 |
118 | Assert.AreEqual(participantC, enemyParticipants[1]);
119 | }
120 |
121 | [Test]
122 | public void GetParticipantWithHighestAgility() {
123 | var participantA = new Participant("Participant A",
124 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
125 |
126 | var participantB = new Participant("Participant B",
127 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
128 |
129 | participantB.ParticipantType = ParticipantType.Player;
130 |
131 | var participantC = new Participant("Participant C",
132 | new Stats(25, 25, 7, 7, 7, 7, 6, 5, 5));
133 |
134 | Assert.AreEqual(participantC,
135 | BattleSystem.GetParticipantWithHighestAgility(new List
136 | { participantA, participantB, participantC }));
137 | }
138 |
139 | [Test]
140 | public void DetermineRemainingParticipants() {
141 | var participantA = new Participant("Participant A",
142 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
143 |
144 | var participantB = new Participant("Participant B",
145 | new Stats(0, 0, 7, 7, 7, 5, 6, 5, 5));
146 |
147 | var participantC = new Participant("Participant C",
148 | new Stats(25, 25, 7, 7, 7, 7, 6, 5, 5));
149 |
150 | Assert.AreEqual(2,
151 | BattleSystem.GetNumberOfRemainingParticipants(new List
152 | { participantA, participantB, participantC }));
153 | }
154 |
155 | public class DetermineAttackDamage {
156 | [Test]
157 | public void CriticalHit() {
158 | var participantA = new Participant("Participant A",
159 | new Stats(22, 22, 12, 12, 8, 6, 8, 8, 2));
160 |
161 | var participantB = new Participant("Participant B",
162 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
163 |
164 | var results = BattleSystem.DetermineAttackDamage(
165 | participantA,
166 | participantB,
167 | new RandomMock(new[] { 1, 1, 64 }));
168 |
169 | // Critical hit
170 | Assert.AreEqual(8, results.Damage);
171 | }
172 |
173 | [Test]
174 | public void Dodge() {
175 | var participantA = new Participant("Participant A",
176 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
177 |
178 | var participantB = new Participant("Participant B",
179 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
180 |
181 | var results = BattleSystem.DetermineAttackDamage(
182 | participantA,
183 | participantB,
184 | new RandomMock(new[] { participantB.Stats.Dodge }));
185 |
186 | // Dodge
187 | Assert.AreEqual(0, results.Damage);
188 | }
189 |
190 | [Test]
191 | public void RegularHit() {
192 | var participantA = new Participant("Participant A",
193 | new Stats(22, 22, 12, 12, 4, 6, 4, 8, 2));
194 |
195 | var participantB = new Participant("Participant B",
196 | new Stats(25, 25, 7, 7, 7, 5, 6, 5, 5));
197 |
198 | var results = BattleSystem.DetermineAttackDamage(
199 | participantA,
200 | participantB,
201 | new RandomMock(new[] { 2, 2, 64 }));
202 |
203 | // Regular hit
204 | Assert.AreEqual(1, results.Damage);
205 | }
206 | }
207 |
208 | public class DetermineEndOfBattle {
209 | [Test]
210 | public void ExperiencePoints() {
211 | var participantA = new Participant("Participant A",
212 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
213 |
214 | participantA.ExperiencePoints = 12;
215 |
216 | Assert.AreEqual(participantA.ExperiencePoints,
217 | BattleSystem.DetermineExperiencePoints(new List { participantA }));
218 | }
219 |
220 | [Test]
221 | public void GoldPoints() {
222 | var participantA = new Participant("Participant A",
223 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
224 |
225 | participantA.GoldPoints = 12;
226 |
227 | Assert.AreEqual(10,
228 | BattleSystem.DetermineGoldPoints(
229 | new List { participantA },
230 | new RandomMock(new[] { 32 })
231 | )
232 | );
233 | }
234 |
235 | [Test]
236 | public void ItemsDropped() {
237 | var participantA = new Participant("Participant A",
238 | new Stats(22, 22, 12, 12, 8, 6, 4, 8, 2));
239 |
240 | var potion = new object();
241 |
242 | var droppableItems = new Dictionary