public MudCharacter[] GetCharactersInRoom() { MudCharacter[] characters=new MudCharacter[PlayersInRoom.Count+NonPlayersInRoom.Count]; PlayersInRoom.ToArray().CopyTo(characters,0); NonPlayersInRoom.ToArray().CopyTo(characters,PlayersInRoom.Count); return characters; }
public bool HasCharacter(MudCharacter c) { MudCharacter[] characters=GetCharactersInRoom(); foreach(MudCharacter other in characters) { if(c==other){return true;} } return false; }
public void Setup(MudCharacter Target) { if (Target == null) { return; } target = Target; target.Effects.Add(this); target.OnEndTurn += BurnTarget; }
public void StartTurn(MudCharacter t) { if (Duration == 0) { Remove(); return; } Duration--; Target.Room.AddActionToQueue(new NullAction(Target, "is stunned and can take no action")); }
public void Setup(MudCharacter target) { if (target == null) { return; } Target = target; target.Effects.Add(this); target.OnStartTurn += StartTurn; }
void BurnTarget(MudCharacter t) { int d; duration--; d = target.TakeDamage(owner, damage); target.Room.NotifyPlayers("\t{0} took {1} damage from {2}'s burn", target.Name, d.ToString(), owner.Name); if (duration <= 0) { Remove(); } }
public static ActionArgs GetArgs(MudCharacter sender, string input) { Regex reg = new Regex("^move (north|south|east|west)$", RegexOptions.IgnoreCase); Match m = reg.Match(input); if (!m.Success) { return(null); } return(new ActionArgs(sender, null, m.Groups[1].ToString().ToLower())); //m.Captures[0] }
public static ActionArgs GetArgs(MudCharacter sender, string input) { Regex regex = new Regex("^wait$", RegexOptions.IgnoreCase); Match m = regex.Match(input); if (!m.Success) { return(null); } return(new ActionArgs(sender)); }
public string Use(MudCharacter user) { int initHp = user.HitPoints; int toHeal = user.MaxHitPoints / 2; toHeal += 1; user.Heal(toHeal); int hp = user.HitPoints; hp = hp - initHp; return(string.Format("{0} used a healing-potion to restore {1} HP", user.Name, hp)); }
public MoveAction(MudCharacter character, string direction) : base(character) { Beneficial = true; MapDirection dir = MapDirection.north; for (int x = 1; x < DirectionString.Length; x++) { if (DirectionString[x] == direction) { dir = (MapDirection)x; } } this.direction = dir; }
public override int TakeDamage(MudCharacter attacker, int damage) { damage = base.TakeDamage(attacker, damage); if (attacker == null || !(attacker is PlayerCharacter)) { return(damage); } if (damage <= 0) { return(damage); } if (!Attackers.Contains(attacker)) { Attackers.Add(attacker as PlayerCharacter); } return(damage); }
public static ActionArgs GetArgs(MudCharacter sender, string input) { Regex regex = new Regex("^equip (\\S+)$", RegexOptions.IgnoreCase); Match m = regex.Match(input); if (!m.Success) { (sender as PlayerCharacter).NotifyPlayer("i don't quite understand"); return(null); } string itemName = m.Groups[1].ToString().ToLower(); if (!(sender as PlayerCharacter).InventoryHasItem(itemName)) { (sender as PlayerCharacter).NotifyPlayer("Can not equip an item you don't have"); return(null); } return(new ActionArgs(sender, null, itemName)); }
public static ActionArgs GetArgs(MudCharacter sender, string input) { MudCharacter[] targets; Regex regex = new Regex("^bonk (\\d{1,2})$", RegexOptions.IgnoreCase); Match m = regex.Match(input); if (!m.Success) { return(null); } int targetnum = int.Parse(m.Groups[1].ToString()); targets = sender.Room.GetCharactersInRoom(); if (targetnum >= targets.Length) { return(null); } return(new ActionArgs(sender, targets[targetnum])); }
public static ActionArgs GetArgs(MudCharacter sender, string input) { MudCharacter[] targets; Regex regex = new Regex("^attack (\\d{1,2})$", RegexOptions.IgnoreCase); Match m = regex.Match(input); if (!m.Success) { (sender as PlayerCharacter).NotifyPlayer("attack what? (target enemies by number)"); return(null); } int targetnum = int.Parse(m.Groups[1].ToString()); targets = sender.Room.GetCharactersInRoom(); if (targetnum >= targets.Length) { (sender as PlayerCharacter).NotifyPlayer("no character present associated with that number"); return(null); } return(new ActionArgs(sender, targets[targetnum])); }
public static ActionArgs GetArgs(MudCharacter sender, string input) { MudCharacter[] targets; Regex regex = new Regex("^use (\\S+) on (\\d{1,2})$", RegexOptions.IgnoreCase); Regex regex2 = new Regex("^use (\\S+)$"); Match m = regex.Match(input); if (!m.Success) { m = regex2.Match(input); if (!m.Success) { (sender as PlayerCharacter).NotifyPlayer("I'm not sure what item you want to use"); return(null); } } string itemName = m.Groups[1].ToString().ToLower(); if (!(sender as PlayerCharacter).InventoryHasItem(itemName)) { (sender as PlayerCharacter).NotifyPlayer("Can not use an item you don't have"); return(null); } MudCharacter target = null; if (m.Captures.Count > 2) { int targetnum = int.Parse(m.Groups[2].ToString()); targets = sender.Room.GetCharactersInRoom(); if (targetnum >= targets.Length) { (sender as PlayerCharacter).NotifyPlayer("There is no target present associated with that number"); return(null); } target = targets[targetnum]; } return(new ActionArgs(sender, target, itemName)); }
public void RemoveCharacter(MudCharacter character) { lock(lockobject){ if(PlayersInRoom.Contains(character as PlayerCharacter)){ PlayersInRoom.Remove(character as PlayerCharacter); if(PlayersInRoom.Count==0){ NonPlayersInRoom.Clear(); } } else{NonPlayersInRoom.Remove(character);} Status = GenerateStatus(); if(PlayersInRoom.Count==0){ NonPlayersInRoom.Clear(); } foreach(PlayerCharacter p in PlayersInRoom) { //p.NewRoomates(); } } }
public static ActionArgs GetActionArgs(PlayerCharacter sender, string toParse) { toParse = toParse.ToLower(); MudCharacter target = null; string arguments = null; string[] words = toParse.Split(' '); if (words.Length > 2) { return(null); } DungeonRoom room = sender.Room; MudCharacter[] characters = room.GetCharactersInRoom(); foreach (string word in words) { if (target != null && arguments == null) { arguments = word; break; } int targetNum; if (int.TryParse(word, out targetNum)) { if (targetNum >= sender.Roomates.Length) { sender.NotifyPlayer("not a valid target"); return(null); } target = sender.Roomates[targetNum]; continue; } arguments = word; } return(new ActionArgs(sender, target, arguments)); }
public virtual void AddCharacter(MudCharacter character) { lock(lockobject){ if(character is PlayerCharacter){ if(PlayersInRoom.Count==0) { SpawnNpcs(); } PlayersInRoom.Add(character as PlayerCharacter); Status=GenerateStatus(); int characterCount=PlayersInRoom.Count+NonPlayersInRoom.Count; (character as PlayerCharacter).NotifyPlayer("\nEntering the room you find: {0}",Message); }else{ NonPlayersInRoom.Add(character); character.SetRoom(this); return; } Status=GenerateStatus(); character.SetRoom(this); if(ActionTask==null){ if(time==DateTime.MinValue)time=DateTime.Now.AddSeconds(timeoutSeconds); ActionTask=Task.Factory.StartNew(new Action(ExecuteQueue)); } foreach(PlayerCharacter p in PlayersInRoom) { //(p!=character) { p.NotifyPlayer("{0} has entered the room",character.StatusString()); //p.NewRoomates(); } } } }
public override string DoAction() { Random rand = new Random(); MudCharacter[] characters; if (!Character.Room.HasCharacter(Target)) { //attempt to pick a new target if (Target is PlayerCharacter) { characters = Character.Room.GetPlayersInRoom(); } else { characters = Character.Room.GetNonPlayersInRoom(); } if (characters.Length == 0) { Target = null; return(""); } Target = characters[rand.Next(0, characters.Length)]; } return(""); }
public BonkAction(MudCharacter character, MudCharacter target) : base(character, target) { Beneficial = false; }
public EquipAction(MudCharacter character, string name) : base(character) { Beneficial = true; ItemName = name; }
public BurnEffect(MudCharacter owner, int damage) { this.owner = owner; this.damage = damage; }
public MageAttack(MudCharacter character, MudCharacter target) : base(character, target) { Beneficial = false; }
public CharacterAction(MudCharacter c) { Character = c; Beneficial = false; }
public AttackAction(MudCharacter Character, MudCharacter target) : base(Character, target) { Beneficial = false; }
public UseAction(MudCharacter c, string arguments) : base(c) { this.arguments = arguments; this.Beneficial = true; }
public void AddCharacter(MudCharacter character, DungeonPosition pos) { Map[pos.X, pos.Y].AddCharacter(character); character.JoinDungeon(this); //character.SetRoom(Map[pos.X,pos.Y]); }
public ActionArgs(MudCharacter sender, MudCharacter target, string argument) { Sender = sender; Target = target; Argument = argument; }
public MoveAction(MudCharacter character, MapDirection dir) : base(character) { direction = dir; }
public ActionArgs(MudCharacter sender) { Sender = sender; Target = null; Argument = null; }