public async void movePlayer() { this.player = await this.zorkService.PlayerServices.changeCasePlayer(this.cellCurrent.PosX, this.cellCurrent.PosY); await trap(); await treasure(); Random rnd = new Random(); if (this.cellCurrent.MonsterRate > rnd.Next(0, 100)) { int rankMonster = this.player.XP; if (50 < rnd.Next(0, 100) && ListMonster.Count < 7) { rankMonster++; } Monster m = ListMonster[rankMonster]; Monster newMonster = new Monster { Name = m.Name, HP = m.HP, AttackRate = m.AttackRate, Attack = m.Attack, Group = player.Id }; Task.Run(async() => { this.monsterCurrent = await this.zorkService.MonsterServices.AddAsync(newMonster); }).Wait(); if (newMonster.Name == "Dragon") { this.annimayionBoss(); } fight(); } gameCell(); }
public async Task Assign(QuestDto quest, MonsterDto monster, ItemDto item) { var q = Mapper.Map <QuestEditDto>(quest); q.MonsterId = monster.Id; q.ItemId = item.Id; await Update(q); }
public async Task <ActionResult> Create(MonsterDto model) { var attr = model.Attributes; model.Attributes = null; await MonsterFacade.CreateMonster(model, attr); return(RedirectToAction("Index")); }
public void RemoveFromCollection(string userEmail, MonsterDto monsterDto) { User user = _userRepository.GetByEmail(userEmail); Monster monster = _monsterRepository.GetById(monsterDto.Id); user.removeFromCollection(monster); _userRepository.Update(user); _userRepository.SaveChanges(); }
public Monster mapMonsterDtoToMonster(MonsterDto monsterDto) { Monster monster = new Monster(); monster.Id = monsterDto.Id; monster.Name = monsterDto.Name; monster.Size = monsterDto.Size; monster.MonsterType = monsterDto.MonsterType; monster.Languages = monsterDto.Languages; monster.Tags = monsterDto.Tags; monster.Alignment = monsterDto.Alignment; monster.ArmourClass = monsterDto.ArmourClass; monster.ArmourType = monsterDto.ArmourType; monster.Hitpoints = monsterDto.Hitpoints; monster.HpFormula = monsterDto.HpFormula; monster.Speed = new Dictionary <string, int>(); monster.Stats = mapStatlineDtoToStatline(monsterDto.Stats); monster.Resistances = monsterDto.Resistances; monster.Immunities = monsterDto.Immunities; monster.ConditionImmunities = monsterDto.ConditionImmunities; monster.Vulnerabilities = monsterDto.Vulnerabilities; monster.Skills = new Dictionary <string, int>(); monster.ChallengeRating = monsterDto.ChallengeRating; monster.Traits = monsterDto.Traits.Select(t => mapTraitDtoToTrait(t)).ToList(); monster.Actions = monsterDto.Actions.Select(a => mapActionDtoToAction(a)).ToList(); monster.Fluff = monsterDto.Fluff; monster.Created = monsterDto.Created; monster.LastUpdated = monsterDto.lastUpdated; foreach (SpeedDto speed in monsterDto.Speeds) { monster.Speed.Add(speed.SpeedName, speed.SpeedValue); } foreach (SkillDto skill in monsterDto.Skills) { monster.Skills.Add(skill.SkillName, skill.SkillMod); } if (monsterDto.Author == null || monsterDto.Author.Email == null || monsterDto.Author.Email.Equals("")) { User author = _userRepository.GetByEmail(monsterDto.AuthorEmail); if (author != null) { monster.Author = author; } else { throw new Exception("no author present on submitted monster"); } } else { monster.Author = mapUserDtoToUser(monsterDto.Author); } return(monster); }
public MonsterResponse UpdateMonsterResponse(MonsterDto monster) => new MonsterResponse { Status = true, StatusText = "Monster Updated", StatusCode = 200, Monsters = new List <MonsterDto> { monster } };
public async Task <Guid> CreateMonster(MonsterDto monster, AttributesDto attr) { using (var uow = UnitOfWorkProvider.Create()) { attr.Id = Guid.NewGuid(); monster.Attributes = attr; monster.Id = _monsterService.Create(monster); await uow.Commit(); return(monster.Id); } }
public async Task <Guid> CreateMonster(MonsterDto monster, int exp = 1) { using (var uow = UnitOfWorkProvider.Create()) { var attr = GenerateAttributesAccordingToExperience(exp); attr.Id = Guid.NewGuid(); monster.Attributes = attr; monster.Id = _monsterService.Create(monster); await uow.Commit(); return(monster.Id); } }
public async Task <bool> AssignAsync(QuestDto quest, MonsterDto monster, ItemDto item) { using (var uow = UnitOfWorkProvider.Create()) { if ((await _questService.GetAsync(quest.Id, false)) == null) { return(false); } await _questService.Assign(quest, monster, item); await uow.Commit(); return(true); } }
public static void Main(string[] args) { var container = new WindsorContainer(); container.Install(new BlInstaller()); var service = container.Resolve <MonsterFacade>(); var user = new MonsterDto() { Name = "lol", Experience = 22 }; var monsterId = service.CreateMonster(user); Console.WriteLine(monsterId); Console.ReadKey(); }
public Monster CreateMonster(long id, int vnum) { MonsterDto monsterDto = _monsterRepository.Select(vnum); if (monsterDto == null) { throw new InvalidOperationException($"Can't find monster {vnum} in database"); } string name = _languageService.GetTranslation(RootKey.MONSTER, monsterDto.NameKey); return(new Monster(id, name) { Vnum = monsterDto.Id, Level = monsterDto.Level }); }
public Game(ZorkService zorkService, int gameId) { this.zorkService = zorkService; this.gameId = gameId; Console.Clear(); getObjectTypes(); getWeapons(); getPlayer(); getMap(); // If monster alive in game load the monster this.monsterCurrent = this.zorkService.MonsterServices.Get(gameId); if (this.monsterCurrent.HP > 0) { fight(); } gameCell(); }
public Npc CreateNpc(long id, int vnum, string name) { MonsterDto monsterDto = _monsterRepository.Select(vnum); if (monsterDto == null) { throw new InvalidOperationException($"Can't find monster {vnum} in database"); } if (string.IsNullOrEmpty(name) || name == "-") { name = _languageService.GetTranslation(RootKey.MONSTER, monsterDto.NameKey); } return(new Npc(id, name) { Vnum = monsterDto.Id, Level = monsterDto.Level }); }
public async Task <ActionResult> Create(QuestDto model) { var monster = new MonsterDto() { Id = model.MonsterId.GetValueOrDefault() }; var item = new ItemDto() { Id = model.ItemId.GetValueOrDefault() }; model.ItemId = null; model.MonsterId = null; model.Id = await QuestFacade.CreateQuest(new QuestDto() { Experience = model.Experience, Gold = model.Gold }); await QuestFacade.AssignAsync(model, monster, item); return(RedirectToAction("Index")); }
public async Task <Tuple <bool, List <string> > > FightAsync(CharacterDto character, MonsterDto monster, QuestDto quest) { var log = new List <string>(); _random = new Random(); if (character.Sickness > DateTime.Now) { var diff = Math.Abs(Math.Floor((character.Sickness - DateTime.Now).Value.TotalSeconds)); log.Add($"You can't fight at the moment. You are too tired and will not be able to fight for {diff} seconds."); return(new Tuple <bool, List <string> >(false, log)); } if (character.CurrentHp <= 0) { log.Add("You can't fight at the moment. You should get some rest, because you are too devasteted."); return(new Tuple <bool, List <string> >(false, log)); } var characterAttr = character.CalculateAttributes(); characterAttr.Hp = character.CurrentHp / 10; //setting hp to current value var combat = Task.Run(() => Combat(characterAttr, monster.Attributes, log)); var result = await combat; using (var uow = UnitOfWorkProvider.Create()) { var updatedUser = new CharacterUpdateDto() { Name = character.Name, CurrentHp = result.Item2, Experience = character.Experience, Gold = character.Gold, Id = character.Id, SkillPoints = character.SkillPoints, Sickness = DateTime.Now.AddMinutes(10) }; if (result.Item1) { updatedUser.Experience += quest.Experience; updatedUser.Gold += quest.Gold; } await _characterService.Update(updatedUser); await uow.Commit(); } return(new Tuple <bool, List <string> >(result.Item1, log)); }
public MonsterDto mapMonsterToMonsterDto(Monster monster) { MonsterDto monsterDto = new MonsterDto(); monsterDto.Id = monster.Id; monsterDto.Name = monster.Name; monsterDto.Size = monster.Size; monsterDto.MonsterType = monster.MonsterType; if (monster.Languages != null) { monsterDto.Languages = monster.Languages; } if (monster.Tags != null) { monsterDto.Tags = monster.Tags; } monsterDto.Alignment = monster.Alignment; monsterDto.ArmourClass = monster.ArmourClass; monsterDto.ArmourType = monster.ArmourType; monsterDto.Hitpoints = monster.Hitpoints; monsterDto.HpFormula = monster.HpFormula; if (monsterDto.Speeds != null) { foreach (string speedName in monster.Speed.Keys) { monsterDto.Speeds.Add(new SpeedDto() { SpeedName = speedName, SpeedValue = monster.Speed[speedName] }); } } if (monster.Stats != null) { monsterDto.Stats = mapStatlineToStatlineDto(monster.Stats); } if (monster.Resistances != null) { monsterDto.Resistances = monster.Resistances; } if (monster.Immunities != null) { monsterDto.Immunities = monster.Immunities; } if (monster.ConditionImmunities != null) { monsterDto.ConditionImmunities = monster.ConditionImmunities; } if (monster.Vulnerabilities != null) { monsterDto.Vulnerabilities = monster.Vulnerabilities; } if (monster.Skills != null) { foreach (string skillName in monster.Skills.Keys) { monsterDto.Skills.Add(new SkillDto() { SkillName = skillName, SkillMod = monster.Skills[skillName] }); } } monsterDto.ChallengeRating = monster.ChallengeRating; if (monster.Traits != null) { monsterDto.Traits = monster.Traits.Select(t => mapTraitToTraitDto(t)).ToList(); } if (monster.Actions != null) { monsterDto.Actions = monster.Actions.Select(a => mapActionToActionDto(a)).ToList(); } monsterDto.Fluff = monster.Fluff; monsterDto.Author = mapUserToUserDto(monster.Author); monsterDto.Created = monster.Created; monsterDto.lastUpdated = monster.LastUpdated; return(monsterDto); }