Modified:
/trunk/ArtheaEngine/Combat.cs
/trunk/ArtheaEngine/Model/Area.cs
/trunk/ArtheaEngine/Model/NonPlayer.cs
/trunk/ArtheaEngine/Model/Object.cs
/trunk/ArtheaEngine/Model/Room.cs
/trunk/ArtheaEngine/Model/World.cs
/trunk/ArtheaServer/MainForm.cs
=======================================
--- /trunk/ArtheaEngine/Combat.cs Wed Apr 20 17:02:20 2011
+++ /trunk/ArtheaEngine/Combat.cs Wed Apr 20 20:08:14 2011
@@ -52,20 +52,30 @@
Victim.Vitals.Life -= damage;
- Attacker.Act("You hit {0} for {1} damage!", Victim,
damage);
- Victim.Act("{0} hits you for {1} damage!", Attacker,
damage);
- Victim.Room.Act(new[]{Attacker, Victim}, "{0} hits {1} for
{2} damage!", Attacker, Victim, damage);
+ DamMessage(Attacker, Victim, damage);
if (Victim.Vitals.Life <= 0)
{
- Victim.WriteLine("~RYou are DEAD!~x");
- Attacker.WriteLine("{0} is ~RDEAD!~x", Victim);
- Victim.Room.Act(new []{Attacker,Victim}, "{0} is
dead", Victim);
- UpdateManager.Remove(Attacker.Fighting);
- UpdateManager.Remove(Victim.Fighting);
+ End();
return;
}
}
+
+ int counterAttacks = Victim.Attack.Count - attacks.Length;
+
+ for (var i = 0; i < counterAttacks; i++)
+ {
+ var damage =
Victim.Attack.RollAgainstValue(Attacker.Defense);
+ Attacker.Vitals.Life -= damage;
+
+ DamMessage(Victim, Attacker, damage);
+
+ if (Attacker.Vitals.Life <= 0)
+ {
+ End();
+ return;
+ }
+ }
if (Attacker is Player)
{
@@ -73,6 +83,22 @@
(Attacker as Player).DisplayPrompt();
}
}
+
+ private void DamMessage(Character a, Character b, int damage)
+ {
+ a.Act("You hit {0} for {1} damage!", b, damage);
+ b.Act("{0} hits you for {1} damage!", a, damage);
+ b.Room.Act(new[] { a, b }, "{0} hits {1} for {2} damage!", a,
b, damage);
+ }
+
+ private void End()
+ {
+ Victim.WriteLine("~RYou are DEAD!~x");
+ Attacker.WriteLine("{0} is ~RDEAD!~x", Victim);
+ Victim.Room.Act(new[] { Attacker, Victim }, "{0} is dead",
Victim);
+ UpdateManager.Remove(Attacker.Fighting);
+ UpdateManager.Remove(Victim.Fighting);
+ }
#endregion Methods
}
=======================================
--- /trunk/ArtheaEngine/Model/Area.cs Wed Apr 20 17:02:20 2011
+++ /trunk/ArtheaEngine/Model/Area.cs Wed Apr 20 20:08:14 2011
@@ -208,10 +208,8 @@
Id = reader.GetInt32(i++);
Name = reader.GetString(i++);
Credits = reader.GetString(i++);
- var world = World.List.SingleOrDefault(x => x.Id ==
reader.GetInt32(i++));
- if (world != null)
- world.Areas.Add(this);
-
+ World = World.List.SingleOrDefault(x => x.Id ==
reader.GetInt32(i++));
+
return i;
}
=======================================
--- /trunk/ArtheaEngine/Model/NonPlayer.cs Tue Apr 19 15:57:05 2011
+++ /trunk/ArtheaEngine/Model/NonPlayer.cs Wed Apr 20 20:08:14 2011
@@ -93,9 +93,7 @@
ShortDescr = reader.GetString(i++);
LongDescr = reader.GetString(i++);
- var area = Area.Lookup(reader.GetInt32(i++));
- if (area != null)
- area.NonPlayers.Add(this);
+ Area = Area.Lookup(reader.GetInt32(i++));
return i;
}
=======================================
--- /trunk/ArtheaEngine/Model/Object.cs Wed Apr 20 00:25:42 2011
+++ /trunk/ArtheaEngine/Model/Object.cs Wed Apr 20 20:08:14 2011
@@ -366,9 +366,7 @@
Cost = reader.GetDecimal(i++);
Flags = reader.GetEnum<ObjectFlag>(i++);
WearFlags = reader.GetEnum<WearFlag>(i++);
- var area = Area.Lookup(reader.GetInt32(i++));
- if (area != null)
- area.Objects.Add(this);
+ Area = Area.Lookup(reader.GetInt32(i++));
Type = reader.GetEnum<ObjectType>(i++);
byte[] data = reader.GetValue(i++) as byte[];
=======================================
--- /trunk/ArtheaEngine/Model/Room.cs Wed Apr 20 17:02:20 2011
+++ /trunk/ArtheaEngine/Model/Room.cs Wed Apr 20 20:08:14 2011
@@ -231,9 +231,7 @@
int i = 0;
Id = reader.GetInt64(i++);
- var area = Area.Lookup(reader.GetInt32(i++));
- if (area != null)
- area.Rooms.Add(this);
+ Area = Area.Lookup(reader.GetInt32(i++));
Name = reader.GetString(i++);
Description = reader.GetString(i++);
Terrain = reader.GetEnum<Terrain>(i++);
=======================================
--- /trunk/ArtheaEngine/Model/World.cs Wed Apr 20 15:25:46 2011
+++ /trunk/ArtheaEngine/Model/World.cs Wed Apr 20 20:08:14 2011
@@ -191,6 +191,7 @@
while (reader.Read())
{
var area = new Area();
+ area.World = this;
area.MapRow(reader);
Area.List.Add(area);
=======================================
--- /trunk/ArtheaServer/MainForm.cs Wed Apr 20 17:02:20 2011
+++ /trunk/ArtheaServer/MainForm.cs Wed Apr 20 20:08:14 2011
@@ -27,25 +27,6 @@
using NLog.Targets;
using Thought.Net.Telnet;
-
- public class ConnectionConfig
- {
- #region Properties
-
- public string PlayerName
- {
- get;
- set;
- }
-
- public SocketInformation SockInfo
- {
- get;
- set;
- }
-
- #endregion Properties
- }
public partial class MainForm : Form
{
@@ -306,5 +287,28 @@
}
#endregion Properties
+
+ #region Nested Types
+
+ public class ConnectionConfig
+ {
+ #region Properties
+
+ public string PlayerName
+ {
+ get;
+ set;
+ }
+
+ public SocketInformation SockInfo
+ {
+ get;
+ set;
+ }
+
+ #endregion Properties
+ }
+
+ #endregion Nested Types
}
}