forked from DanielHazzard/Cure-Please
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PartyBuffs.cs
85 lines (69 loc) · 2.57 KB
/
PartyBuffs.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
76
77
78
79
80
81
82
83
84
85
namespace CurePlease
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Linq;
using static Form1;
public partial class PartyBuffs : Form
{
private Form1 f1;
public class BuffList
{
public string ID { get; set; }
public string Name { get; set; }
}
public List<BuffList> XMLBuffList = new List<BuffList>();
public PartyBuffs(Form1 f)
{
this.StartPosition = FormStartPosition.CenterScreen;
InitializeComponent();
f1 = f;
if (f1.setinstance2.Enabled == true)
{
// Create the required List
// Read the Buffs file a generate a List to call.
foreach (XElement BuffElement in XElement.Load("Resources/Buffs.xml").Elements("o"))
{
XMLBuffList.Add(new BuffList() { ID = BuffElement.Attribute("id").Value, Name = BuffElement.Attribute("en").Value });
}
}
else
{
MessageBox.Show("No character was selected as the power leveler, this can not be opened yet.");
}
}
private void update_effects_Tick(object sender, EventArgs e)
{
ailment_list.Text = "";
// Search through current active party buffs
foreach (BuffStorage ailment in f1.ActiveBuffs)
{
// First add Character name and a Line Break.
ailment_list.AppendText(ailment.CharacterName.ToUpper() + "\n");
// Now create a list and loop through each buff and name them
List<string> named_buffs = ailment.CharacterBuffs.Split(',').ToList();
int i = 1;
int count = named_buffs.Count();
foreach (string acBuff in named_buffs)
{
i++;
var found_Buff = XMLBuffList.Find(r => r.ID == acBuff);
if (found_Buff != null)
{
if (i == count)
{
ailment_list.AppendText(found_Buff.Name + " (" + acBuff + ") ");
}
else
{
ailment_list.AppendText(found_Buff.Name + " (" + acBuff + "), ");
}
}
}
ailment_list.AppendText("\n\n");
}
}
}
}