Пример #1
0
		public MudCharacter[] GetCharactersInRoom()
		{
			MudCharacter[] characters=new MudCharacter[PlayersInRoom.Count+NonPlayersInRoom.Count];
			PlayersInRoom.ToArray().CopyTo(characters,0);
			NonPlayersInRoom.ToArray().CopyTo(characters,PlayersInRoom.Count);
			return characters;
		}
Пример #2
0
		public bool HasCharacter(MudCharacter c)
		{
			MudCharacter[] characters=GetCharactersInRoom();
			foreach(MudCharacter other in characters)
			{
				if(c==other){return true;}
			}
			return false;
		}
Пример #3
0
 public void Setup(MudCharacter Target)
 {
     if (Target == null)
     {
         return;
     }
     target = Target;
     target.Effects.Add(this);
     target.OnEndTurn += BurnTarget;
 }
Пример #4
0
 public void StartTurn(MudCharacter t)
 {
     if (Duration == 0)
     {
         Remove();
         return;
     }
     Duration--;
     Target.Room.AddActionToQueue(new NullAction(Target, "is stunned and can take no action"));
 }
Пример #5
0
        public void Setup(MudCharacter target)
        {
            if (target == null)
            {
                return;
            }

            Target = target;
            target.Effects.Add(this);
            target.OnStartTurn += StartTurn;
        }
Пример #6
0
        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();
            }
        }
Пример #7
0
        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]
        }
Пример #8
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));
        }
Пример #9
0
        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));
        }
Пример #10
0
        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;
        }
Пример #11
0
 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);
 }
Пример #12
0
        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));
        }
Пример #13
0
        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]));
        }
Пример #14
0
        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]));
        }
Пример #15
0
        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));
        }
Пример #16
0
		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();
				}

			}
		}
Пример #17
0
        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));
        }
Пример #18
0
		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();
					}
				}
				
			}
		}
Пример #19
0
        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("");
        }
Пример #20
0
 public BonkAction(MudCharacter character, MudCharacter target) : base(character, target)
 {
     Beneficial = false;
 }
Пример #21
0
 public EquipAction(MudCharacter character, string name) : base(character)
 {
     Beneficial = true;
     ItemName   = name;
 }
Пример #22
0
 public BurnEffect(MudCharacter owner, int damage)
 {
     this.owner  = owner;
     this.damage = damage;
 }
Пример #23
0
 public MageAttack(MudCharacter character, MudCharacter target) : base(character, target)
 {
     Beneficial = false;
 }
Пример #24
0
 public CharacterAction(MudCharacter c)
 {
     Character  = c;
     Beneficial = false;
 }
Пример #25
0
 public AttackAction(MudCharacter Character, MudCharacter target) : base(Character, target)
 {
     Beneficial = false;
 }
Пример #26
0
 public UseAction(MudCharacter c, string arguments) : base(c)
 {
     this.arguments  = arguments;
     this.Beneficial = true;
 }
Пример #27
0
 public void AddCharacter(MudCharacter character, DungeonPosition pos)
 {
     Map[pos.X, pos.Y].AddCharacter(character);
     character.JoinDungeon(this);
     //character.SetRoom(Map[pos.X,pos.Y]);
 }
Пример #28
0
 public ActionArgs(MudCharacter sender, MudCharacter target, string argument)
 {
     Sender   = sender;
     Target   = target;
     Argument = argument;
 }
Пример #29
0
 public MoveAction(MudCharacter character, MapDirection dir) : base(character)
 {
     direction = dir;
 }
Пример #30
0
 public ActionArgs(MudCharacter sender)
 {
     Sender   = sender;
     Target   = null;
     Argument = null;
 }