public int GetLevel(int party_size) { if (party_size == 0) { return(-1); } int xP = this.GetXP(); if (Session.Project != null) { xP = (int)((double)xP / Session.Project.CampaignSettings.XP); } xP /= party_size; int num = 0; int num1 = 2147483647; for (int i = 0; i <= 40; i++) { int creatureXP = Experience.GetCreatureXP(i); int num2 = Math.Abs(xP - creatureXP); if (num2 < num1) { num = i; num1 = num2; } } return(num); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.fParty == null) { return; } System.Drawing.Font font = new System.Drawing.Font(this.Font.FontFamily, 7f); Rectangle rectangle = new Rectangle(0, 4, this.get_x(this.fXP), base.Height - 8); if (rectangle.Width > 0) { Brush linearGradientBrush = new LinearGradientBrush(rectangle, SystemColors.Control, SystemColors.ControlDark, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(linearGradientBrush, rectangle); } int num = Math.Max(this.get_min_level(), 1); int maxLevel = this.get_max_level(); for (int i = num; i != maxLevel; i++) { int creatureXP = Experience.GetCreatureXP(i) * this.fParty.Size; int _x = this.get_x(creatureXP); e.Graphics.DrawLine(Pens.Black, new Point(_x, 1), new Point(_x, base.Height - 3)); e.Graphics.DrawString(i.ToString(), font, SystemBrushes.WindowText, new PointF((float)_x, 1f)); } }
/// <summary> /// Calculates the level of the encounter. /// </summary> /// <param name="party_size">The party size.</param> /// <returns>Returns the encounter level.</returns> public int GetLevel(int party_size) { if (party_size == 0) { return(-1); } int xp = GetXP(); if (Session.Project != null) { xp = (int)(xp / Session.Project.CampaignSettings.XP); } xp /= party_size; int result = 0; int min_diff = int.MaxValue; for (int cl = 0; cl <= 40; ++cl) { int level_xp = Experience.GetCreatureXP(cl); int diff = Math.Abs(xp - level_xp); if (diff < min_diff) { result = cl; min_diff = diff; } } return(result); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (fParty == null) { return; } Font f = new Font(Font.FontFamily, 7); // Draw XP gauge const int delta_y = 4; Rectangle rect = new Rectangle(0, delta_y, get_x(fXP), Height - (2 * delta_y)); if (rect.Width > 0) { Brush b = new LinearGradientBrush(rect, SystemColors.Control, SystemColors.ControlDark, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(b, rect); } int min_lvl = Math.Max(get_min_level(), 1); int max_lvl = get_max_level(); for (int level = min_lvl; level != max_lvl; ++level) { int xp = Experience.GetCreatureXP(level) * fParty.Size; int x = get_x(xp); e.Graphics.DrawLine(Pens.Black, new Point(x, 1), new Point(x, Height - 3)); e.Graphics.DrawString(level.ToString(), f, SystemBrushes.WindowText, new PointF(x, 1)); } }
private int get_x(int xp) { int creatureXP = Experience.GetCreatureXP(this.get_min_level()) * this.fParty.Size; int num = Experience.GetCreatureXP(this.get_max_level()) * this.fParty.Size; int num1 = Math.Min(this.fXP, creatureXP); int num2 = Math.Max(this.fXP, num) - num1; return((xp - num1) * base.Width / num2); }
public static int GetXP(int level, int complexity) { int creatureXP = Experience.GetCreatureXP(level) * complexity; if (Session.Project != null) { creatureXP = (int)((double)creatureXP * Session.Project.CampaignSettings.XP); } return(creatureXP); }
/// <summary> /// Calculates the XP value of a challenge of the given level and complexity. /// </summary> /// <param name="level">The level.</param> /// <param name="complexity">The complexity.</param> /// <returns>Returns the XP value.</returns> public static int GetXP(int level, int complexity) { int xp = Experience.GetCreatureXP(level) * complexity; if (Session.Project != null) { xp = (int)(xp * Session.Project.CampaignSettings.XP); } return(xp); }
private void update_view() { this.ItemList.Items.Clear(); foreach (EncounterSlot slot in this.fEncounter.Slots) { ListViewItem green = this.ItemList.Items.Add(slot.Card.Title); green.SubItems.Add(slot.Card.Info); ListViewItem.ListViewSubItemCollection subItems = green.SubItems; int count = slot.CombatData.Count; subItems.Add(count.ToString()); green.SubItems.Add(slot.XP.ToString()); green.Tag = slot; ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global); Difficulty threatDifficulty = AI.GetThreatDifficulty(creature.Level + slot.Card.LevelAdjustment, this.fPartyLevel); if (threatDifficulty == Difficulty.Trivial) { green.ForeColor = Color.Green; } if (threatDifficulty != Difficulty.Extreme) { continue; } green.ForeColor = Color.Red; } foreach (Trap trap in this.fEncounter.Traps) { ListViewItem listViewItem = this.ItemList.Items.Add(trap.Name); listViewItem.SubItems.Add(trap.Info); listViewItem.SubItems.Add("1"); ListViewItem.ListViewSubItemCollection listViewSubItemCollections = listViewItem.SubItems; int creatureXP = Experience.GetCreatureXP(trap.Level); listViewSubItemCollections.Add(creatureXP.ToString()); listViewItem.Tag = trap; } foreach (SkillChallenge skillChallenge in this.fEncounter.SkillChallenges) { ListViewItem listViewItem1 = this.ItemList.Items.Add(skillChallenge.Name); listViewItem1.SubItems.Add(skillChallenge.Info); listViewItem1.SubItems.Add("1"); ListViewItem.ListViewSubItemCollection subItems1 = listViewItem1.SubItems; int xP = skillChallenge.GetXP(); subItems1.Add(xP.ToString()); listViewItem1.Tag = skillChallenge; } if (this.ItemList.Items.Count == 0) { ListViewItem grayText = this.ItemList.Items.Add("(none)"); grayText.ForeColor = SystemColors.GrayText; } this.ItemList.Sort(); this.XPLbl.Text = string.Concat(this.fEncounter.GetXP(), " XP"); this.DiffLbl.Text = string.Concat("Difficulty: ", this.fEncounter.GetDifficulty(this.fPartyLevel, Session.Project.Party.Size)); }
void update_view() { ItemList.Items.Clear(); foreach (EncounterSlot slot in fEncounter.Slots) { ListViewItem lvi = ItemList.Items.Add(slot.Card.Title); lvi.SubItems.Add(slot.Card.Info); lvi.SubItems.Add(slot.CombatData.Count.ToString()); lvi.SubItems.Add(slot.XP.ToString()); lvi.Tag = slot; ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global); Difficulty diff = AI.GetThreatDifficulty(creature.Level + slot.Card.LevelAdjustment, fPartyLevel); if (diff == Difficulty.Trivial) { lvi.ForeColor = Color.Green; } if (diff == Difficulty.Extreme) { lvi.ForeColor = Color.Red; } } foreach (Trap trap in fEncounter.Traps) { ListViewItem lvi = ItemList.Items.Add(trap.Name); lvi.SubItems.Add(trap.Info); lvi.SubItems.Add("1"); lvi.SubItems.Add(Experience.GetCreatureXP(trap.Level).ToString()); lvi.Tag = trap; } foreach (SkillChallenge sc in fEncounter.SkillChallenges) { ListViewItem lvi = ItemList.Items.Add(sc.Name); lvi.SubItems.Add(sc.Info); lvi.SubItems.Add("1"); lvi.SubItems.Add(sc.GetXP().ToString()); lvi.Tag = sc; } if (ItemList.Items.Count == 0) { ListViewItem lvi = ItemList.Items.Add("(none)"); lvi.ForeColor = SystemColors.GrayText; } ItemList.Sort(); XPLbl.Text = fEncounter.GetXP() + " XP"; DiffLbl.Text = "Difficulty: " + fEncounter.GetDifficulty(fPartyLevel, Session.Project.Party.Size); }
int get_x(int xp) { int trivial = Experience.GetCreatureXP(get_min_level()) * fParty.Size; int extreme = Experience.GetCreatureXP(get_max_level()) * fParty.Size; int min = Math.Min(fXP, trivial); int max = Math.Max(fXP, extreme); int range = max - min; int delta = xp - min; return((delta * Width) / range); }
void update_list() { ItemList.Items.Clear(); switch (fType) { case OverviewType.Encounters: { foreach (PlotPoint pp in fPoints) { if (pp.Element == null) { continue; } if (pp.Element is Encounter) { Encounter enc = pp.Element as Encounter; string creatures = ""; foreach (EncounterSlot slot in enc.AllSlots) { if (creatures != "") { creatures += ", "; } creatures += slot.Card.Title; if (slot.CombatData.Count != 1) { creatures += " (x" + slot.CombatData.Count + ")"; } } foreach (Trap trap in enc.Traps) { if (creatures != "") { creatures += ", "; } creatures += trap.Name; } ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(enc.GetXP() + " XP; " + creatures); lvi.Tag = new Pair <PlotPoint, Encounter>(pp, enc); } } } break; case OverviewType.Traps: { foreach (PlotPoint pp in fPoints) { if (pp.Element == null) { continue; } if (pp.Element is TrapElement) { TrapElement te = pp.Element as TrapElement; ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(Experience.GetCreatureXP(te.Trap.Level) + " XP; " + te.Trap.Name); lvi.Tag = new Pair <PlotPoint, Trap>(pp, te.Trap); } if (pp.Element is Encounter) { Encounter enc = pp.Element as Encounter; foreach (Trap trap in enc.Traps) { ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(Experience.GetCreatureXP(trap.Level) + " XP; " + trap.Name); lvi.Tag = new Pair <PlotPoint, Trap>(pp, trap); } } } } break; case OverviewType.SkillChallenges: { foreach (PlotPoint pp in fPoints) { if (pp.Element == null) { continue; } if (pp.Element is SkillChallenge) { SkillChallenge sc = pp.Element as SkillChallenge; ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(sc.GetXP() + " XP"); lvi.Tag = new Pair <PlotPoint, SkillChallenge>(pp, sc); } if (pp.Element is Encounter) { Encounter enc = pp.Element as Encounter; foreach (SkillChallenge sc in enc.SkillChallenges) { ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(sc.GetXP() + " XP"); lvi.Tag = new Pair <PlotPoint, SkillChallenge>(pp, sc); } } } } break; case OverviewType.Treasure: { foreach (PlotPoint pp in fPoints) { foreach (Parcel parcel in pp.Parcels) { string name = (parcel.Name != "") ? parcel.Name : "(undefined parcel)"; ListViewItem lvi = ItemList.Items.Add(pp.Name); lvi.SubItems.Add(name + ": " + parcel.Details); lvi.Tag = new Pair <PlotPoint, Parcel>(pp, parcel); } } } break; } if (ItemList.Items.Count == 0) { ListViewItem lvi = ItemList.Items.Add("(no items)"); lvi.ForeColor = SystemColors.GrayText; } ItemList.Sort(); }
private void update_list() { this.ItemList.Items.Clear(); switch (this.fType) { case OverviewType.Encounters: { List <PlotPoint> .Enumerator enumerator = this.fPoints.GetEnumerator(); try { while (enumerator.MoveNext()) { PlotPoint current = enumerator.Current; if (current.Element == null || !(current.Element is Encounter)) { continue; } Encounter element = current.Element as Encounter; string str = ""; List <EncounterSlot> .Enumerator enumerator1 = element.AllSlots.GetEnumerator(); try { while (enumerator1.MoveNext()) { EncounterSlot encounterSlot = enumerator1.Current; if (str != "") { str = string.Concat(str, ", "); } str = string.Concat(str, encounterSlot.Card.Title); if (encounterSlot.CombatData.Count == 1) { continue; } object obj = str; object[] count = new object[] { obj, " (x", encounterSlot.CombatData.Count, ")" }; str = string.Concat(count); } } finally { ((IDisposable)enumerator1).Dispose(); } List <Trap> .Enumerator enumerator2 = element.Traps.GetEnumerator(); try { while (enumerator2.MoveNext()) { Trap trap = enumerator2.Current; if (str != "") { str = string.Concat(str, ", "); } str = string.Concat(str, trap.Name); } } finally { ((IDisposable)enumerator2).Dispose(); } ListViewItem pair = this.ItemList.Items.Add(current.Name); pair.SubItems.Add(string.Concat(element.GetXP(), " XP; ", str)); pair.Tag = new Pair <PlotPoint, Encounter>(current, element); } break; } finally { ((IDisposable)enumerator).Dispose(); } } case OverviewType.Traps: { List <PlotPoint> .Enumerator enumerator3 = this.fPoints.GetEnumerator(); try { while (enumerator3.MoveNext()) { PlotPoint plotPoint = enumerator3.Current; if (plotPoint.Element == null) { continue; } if (plotPoint.Element is TrapElement) { TrapElement trapElement = plotPoint.Element as TrapElement; ListViewItem listViewItem = this.ItemList.Items.Add(plotPoint.Name); listViewItem.SubItems.Add(string.Concat(Experience.GetCreatureXP(trapElement.Trap.Level), " XP; ", trapElement.Trap.Name)); listViewItem.Tag = new Pair <PlotPoint, Trap>(plotPoint, trapElement.Trap); } if (!(plotPoint.Element is Encounter)) { continue; } List <Trap> .Enumerator enumerator4 = (plotPoint.Element as Encounter).Traps.GetEnumerator(); try { while (enumerator4.MoveNext()) { Trap current1 = enumerator4.Current; ListViewItem pair1 = this.ItemList.Items.Add(plotPoint.Name); pair1.SubItems.Add(string.Concat(Experience.GetCreatureXP(current1.Level), " XP; ", current1.Name)); pair1.Tag = new Pair <PlotPoint, Trap>(plotPoint, current1); } } finally { ((IDisposable)enumerator4).Dispose(); } } break; } finally { ((IDisposable)enumerator3).Dispose(); } } case OverviewType.SkillChallenges: { List <PlotPoint> .Enumerator enumerator5 = this.fPoints.GetEnumerator(); try { while (enumerator5.MoveNext()) { PlotPoint plotPoint1 = enumerator5.Current; if (plotPoint1.Element == null) { continue; } if (plotPoint1.Element is SkillChallenge) { SkillChallenge skillChallenge = plotPoint1.Element as SkillChallenge; ListViewItem listViewItem1 = this.ItemList.Items.Add(plotPoint1.Name); listViewItem1.SubItems.Add(string.Concat(skillChallenge.GetXP(), " XP")); listViewItem1.Tag = new Pair <PlotPoint, SkillChallenge>(plotPoint1, skillChallenge); } if (!(plotPoint1.Element is Encounter)) { continue; } List <SkillChallenge> .Enumerator enumerator6 = (plotPoint1.Element as Encounter).SkillChallenges.GetEnumerator(); try { while (enumerator6.MoveNext()) { SkillChallenge skillChallenge1 = enumerator6.Current; ListViewItem pair2 = this.ItemList.Items.Add(plotPoint1.Name); pair2.SubItems.Add(string.Concat(skillChallenge1.GetXP(), " XP")); pair2.Tag = new Pair <PlotPoint, SkillChallenge>(plotPoint1, skillChallenge1); } } finally { ((IDisposable)enumerator6).Dispose(); } } break; } finally { ((IDisposable)enumerator5).Dispose(); } } case OverviewType.Treasure: { List <PlotPoint> .Enumerator enumerator7 = this.fPoints.GetEnumerator(); try { while (enumerator7.MoveNext()) { PlotPoint current2 = enumerator7.Current; List <Parcel> .Enumerator enumerator8 = current2.Parcels.GetEnumerator(); try { while (enumerator8.MoveNext()) { Parcel parcel = enumerator8.Current; string str1 = (parcel.Name != "" ? parcel.Name : "(undefined parcel)"); ListViewItem listViewItem2 = this.ItemList.Items.Add(current2.Name); listViewItem2.SubItems.Add(string.Concat(str1, ": ", parcel.Details)); listViewItem2.Tag = new Pair <PlotPoint, Parcel>(current2, parcel); } } finally { ((IDisposable)enumerator8).Dispose(); } } break; } finally { ((IDisposable)enumerator7).Dispose(); } } } if (this.ItemList.Items.Count == 0) { ListViewItem grayText = this.ItemList.Items.Add("(no items)"); grayText.ForeColor = SystemColors.GrayText; } this.ItemList.Sort(); }