-
Notifications
You must be signed in to change notification settings - Fork 0
/
BattleTest.cs
75 lines (61 loc) · 2.08 KB
/
BattleTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using HumanRamen.Battle.Components;
using HumanRamen.Battle.Systems;
using Microsoft.Xna.Framework;
using MonoGame.Extended.Entities;
using Xunit;
using static HumanRamen.Battle.Components.TurnComponent;
namespace BattleSystem.Systems.Tests
{
public class BattleSystemTest : IDisposable
{
private World _world;
public BattleSystemTest()
{
_world = new WorldBuilder()
.AddSystem(new AiSystem())
.AddSystem(new ActionSystem())
.AddSystem(new TurnSystem())
.AddSystem(new ABattleSystem())
.Build();
}
[Fact]
public void Scenario()
{
var player = _world.CreateEntity();
player.Attach(new PlayerComponent());
player.Attach(new StatusComponent());
player.Attach(new PropComponent());
var playerActions = new ActionsComponent();
player.Attach(playerActions);
var enemies = new List<Entity>();
for (var i = 0; i < 10; ++i)
{
var enemy = _world.CreateEntity();
enemy.Attach(new StatusComponent());
enemy.Attach(new PropComponent());
enemy.Attach(new ActionsComponent());
enemies.Add(enemy);
}
var battle = _world.CreateEntity();
battle.Attach(new BattleComponent(enemies, player));
// TODO: BattleSystem scenario
for (var i = 0; i < 20; ++i)
{
_world.Update(new GameTime());
var turn = battle.Get<TurnComponent>();
if (turn != null && turn.State == Turn.Player)
{
battle.Get<ActionQueueComponent>()
.Add(new ActionQueueItem(playerActions.DrinkCoffee, player));
battle.Attach(new TurnEndComponent());
}
}
}
void IDisposable.Dispose()
{
_world.Dispose();
}
}
}