public async Task information(CommandContext ctx, string monsterName) { MonsterService MS = new MonsterService(); var result = MS.GetByName(monsterName); await ctx.RespondAsync("Monster CR is " + result.CR); }
public IndividualStatBlock GetIndividualByName(string name) { MonsterService _monsterService = new MonsterService(ConnectionString); monster tempMonster = _monsterService.GetMonsterByName(name); return((IndividualStatBlock)MapThisToIndividualStatBlockObject(tempMonster)); }
public IndividualStatBlock GetByNameSource(string indiv_name, string source, string altNameForm) { MonsterService _monsterService = new MonsterService(ConnectionString); monster tempMonster = _monsterService.GetByNameSource(indiv_name, source, altNameForm); return((IndividualStatBlock)MapThisToIndividualStatBlockObject(tempMonster)); }
// GET: Monster public ActionResult Index() { monsterService = new MonsterService(); var model = monsterService.GetAll().ToList(); return(View(model)); }
public static IActionResult GetMonster([HttpTrigger(AuthorizationLevel.Function, "post", Route = "getMonster/{playerLevel}")] HttpRequest req, ILogger log, int playerLevel) { log.LogInformation($"Getting the next monster using playerLevel"); Monster m = MonsterService.GetMonster(playerLevel); return((ActionResult) new ObjectResult(m)); }
public MonsterStatBlock GetBestiaryMonsterByNamePathfinderDefault(string name) { MonsterService _monsterService = new MonsterService(ConnectionString); monster tempMonster = _monsterService.GetBestiaryMonsterByNamePathfinderDefault(name); return(MapThisToMonsterStatBlockObject(tempMonster)); }
public bool UpdateMonster(MonsterStatBlock SB, ref IEnumerable <string> Error) { MonsterService _monsterService = new MonsterService(ConnectionString); Error = _monsterService.UpdateMonster(MapThisToMonsterObject(SB)); return(Error.Any() ? true : false); }
public MonsterStatBlock GetMonsterByName(string name) { MonsterService _monsterService = new MonsterService(ConnectionString); monster tempMonster = _monsterService.GetMonsterByName(name); return(MapThisToMonsterStatBlockObject(tempMonster)); }
public BusinessLayerTests() { var options = SqliteInMemory.CreateOptions <ApplicationContext>(); context = new ApplicationContext(options); context.Database.EnsureCreated(); // Seed Inventory content context.SeedItemTypes(); context.SeedItemImages(); // Seed Monster content context.SeedMonsterModels(); context.SeedMonsterNames(); context.SeedMonsterTitles(); inventoryRepository = new InventoryRepository(context); inventoryService = new InventoryService(inventoryRepository); playerRepository = new PlayerRepository(context); playerService = new PlayerService(playerRepository); monsterRepository = new MonsterRepository(context); monsterService = new MonsterService(monsterRepository); knightRepository = new KnightRepository(context); landmarkRepository = new LandmarkRepository(context); landmarkService = new LandmarkService(landmarkRepository, knightRepository); }
public static void CreateMonster() { var serviceProvider4 = DIConfiguration.ConfigurazioneMonster(); MonsterService MonsterService = serviceProvider4.GetService <MonsterService>(); Console.WriteLine("Categoria del mostro: "); string c = Console.ReadLine(); Console.WriteLine("Livello: "); int l = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Arma: "); string weaponName = Console.ReadLine(); Console.WriteLine("Punti danno dell'arma MUOOOSTROSA: "); int damagePoint = Convert.ToInt32(Console.ReadLine()); Monster m = new Monster() { classPerson = c, level = l, weapon = new Weapon { name = weaponName, damagePoint = damagePoint } }; MonsterService.CreateMonster(m); }
public Form1() { InitializeComponent(); game = IOC.Resolve <Game>(); rand = IOC.Resolve <RandomContext>(); monsterS = IOC.Resolve <MonsterService>(); }
public static Monster GetMonster(Hero fightingHero) { var serviceProvider4 = DIConfiguration.ConfigurazioneMonster(); MonsterService MonsterService = serviceProvider4.GetService <MonsterService>(); var monster = MonsterService.GetAllMonster(fightingHero); //mi rende i mostri con livello uguale o mini var random = new Random(); var serviceProvider3 = DIConfiguration.ConfigurazioneLevel(); LevelService levelService = serviceProvider3.GetService <LevelService>(); var Levels = levelService.GetLivelliInfo(); int index = random.Next(monster.Count); Monster fightingMonster = monster[index]; for (int i = 0; i < Levels.Count; i++) { if (Levels[i].livello == fightingMonster.level) { fightingMonster.lifePoint = Levels[i].lifePoint; } } Console.WriteLine("Stai sfidando {0} la cui arma è {1}", fightingMonster.classPerson, fightingMonster.weapon.name); return(fightingMonster); }
protected void Page_Load(object sender, EventArgs e) { monsterService = new MonsterService(); List <Common.Entities.Monster> list = monsterService.GetAll().ToList(); GridView1.DataSource = list; GridView1.DataBind(); }
public void VerificaSeOsNumerosNaoSeRepetem() { MonsterService x = new MonsterService(); for (int i = 0; i < 100; i++) { var result = x.GetMonterDices(5); var monsterNumbers = result.Distinct().ToArray(); Assert.AreEqual(result.Length, monsterNumbers.Length); } }
public ActionResult Create(Monster model) { monsterService = new MonsterService(); var chk = monsterService.Add(model); if (chk) { return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
public ActionResult Edit(Monster model) { monsterService = new MonsterService(); var chk = monsterService.Update(model); if (chk) { return(RedirectToAction("Index")); } else { return(View(model)); } }
//Delete功能 public ActionResult Delete(int?id) { if (id == null) { return(HttpNotFound()); } monsterService = new MonsterService(); var chk = monsterService.Delete((int)id); if (chk) { return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
//Edit功能 public ActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } monsterService = new MonsterService(); var chk = monsterService.Query((int)id); if (chk == null) { return(HttpNotFound()); } else { return(View(chk)); } }
public void SetUp() { _unitOfWorkFactory = new FakeUnitOfWorkFactory(); _authorizationUtil = Substitute.For <IAuthorizationUtil>(); _activeStatsModifierUtil = Substitute.For <IActiveStatsModifierUtil>(); _notificationSessionFactory = new FakeNotificationSessionFactory(); _jsonUtil = Substitute.For <IJsonUtil>(); _timeService = Substitute.For <ITimeService>(); _itemService = Substitute.For <IItemService>(); _service = new MonsterService( _unitOfWorkFactory, _authorizationUtil, _activeStatsModifierUtil, _notificationSessionFactory, _jsonUtil, _timeService, _itemService ); }
private void InitializeCoreServices() { Services = new ServiceManager(this); // Create a map generation servivce. MapGenerator = new MapGenerationService(); Services.RegisterService(MapGenerator); // Create an Random Number Generator service. RNG = new RngService(); Services.RegisterService(RNG); // Create the monster generation service. MonsterGenerationService monsterGen = new MonsterGenerationService(); Services.RegisterService(monsterGen); // Create the mosnter service. MonsterService monsters = new MonsterService(); Services.RegisterService(monsters); }
public void Start() { var monster = MonsterService.GetRandom(); Monster = monster; Console.Clear(); Console.WriteLine($"Tu te fais agressé par {Monster.Name} !"); while (true) { PlayerTurn(); if (Monster.HP <= 0 || EndFight) { break; } MonsterTurn(); if (Globals.Player.HP <= 0) { GameOver(); break; } } }
public MonstersController(ApplicationDbContext context) { _context = context; monsterService = new MonsterService(_context); }
/// <summary> /// Starts this instance. /// </summary> /// <returns>The task.</returns> public virtual async Task Start() { Logger.LogStart(">> Loading vocations"); VocationXmlReader vocationXmlReader = new VocationXmlReader(); IEnumerable <IVocation> vocations = await vocationXmlReader.LoadAsync(Settings.Default.Vocations_Xml); _vocationService = new VocationService(vocations); Logger.LogDone(); Logger.LogStart(">> Loading items"); ItemReader itemReader = new ItemReader(); IEnumerable <IItem> items = await itemReader.LoadAsync(Settings.Default.Items_Otb); _itemService = new ItemService(items); ItemXmlReader itemXmlReader = new ItemXmlReader(_itemService); await itemXmlReader.LoadAsync(Settings.Default.Items_Xml); Logger.LogDone(); Logger.LogStart(">> Loading spells"); SpellXmlReader spellXmlReader = new SpellXmlReader(); IEnumerable <ISpell> spells = await spellXmlReader.LoadAsync(Settings.Default.Spells_Xml); _spellService = new SpellService(spells); Logger.LogDone(); Logger.LogStart(">> Loading monsters"); MonsterXmlReader monsterXmlReader = new MonsterXmlReader(_spellService); IEnumerable <IMonster> monsters = await monsterXmlReader.LoadAsync(Settings.Default.Monsters_Xml); _monsterService = new MonsterService(monsters); Logger.LogDone(); Logger.LogStart(">> Loading npcs"); NpcXmlReader npcXmlReader = new NpcXmlReader(); IEnumerable <INpc> npcs = await npcXmlReader.LoadAsync(Settings.Default.Npcs_Xml); _npcService = new NpcService(npcs); Logger.LogDone(); Logger.LogStart(">> Loading map"); MapReader mapReader = new MapReader(_itemService); WorldMap map = await mapReader.LoadAsync(Settings.Default.Map_Otb); Logger.LogDone(); Logger.LogStart(">> Loading outfits"); DrkOutfitReader outfitReader = new DrkOutfitReader(); IEnumerable <IOutfit> outfits = await outfitReader.LoadAsync(Settings.Default.Outfits_Xml); _outfitService = new OutfitService(outfits); Logger.LogDone(); Logger.LogStart(">> Loading mounts"); DrkMountReader mountReader = new DrkMountReader(); IEnumerable <IMount> mounts = await mountReader.LoadAsync(Settings.Default.Mounts_Xml); _mountService = new MountService(mounts); Logger.LogDone(); Logger.LogStart(">> Loading channels"); // TODO: Channels are broken. They should be handled by a category like ChannelType (e.g.: Public, Private, Guild, Party, etc.), then each category has an ID // TODO: Eventually loading channels this away should be replaced. // TODO Alternatively, we could move the specific implementation of LocalChannel to a scripting language (like Lua) // TODO: This could be also converted into a more modular approach (like a CS-Script) IDictionary <ChannelType, IChannel> channels = new Dictionary <ChannelType, IChannel>(); channels.Add(ChannelType.Local, new LocalChannel()); channels.Add(ChannelType.Loot, new LootChannel()); channels.Add(ChannelType.Advertising, new AdvertisingChannel()); channels.Add(ChannelType.AdvertisingRookgaard, new AdvertisingRookgaardChannel()); channels.Add(ChannelType.English, new EnglishChannel()); channels.Add(ChannelType.Help, new HelpChannel()); channels.Add(ChannelType.World, new WorldChannel()); Logger.LogDone(); Logger.LogStart(">> Initializing town services"); _townService = new TownService(map.Towns.Values); Logger.LogDone(); Logger.LogStart(">> Initializing tile services"); _tileService = new TileService(map.Tiles.Values); Logger.LogDone(); // TODO: Remove this after project is complete InitializeTest(); Logger.LogStart(">> Initializing repositories"); _accountsRepository = new Repository <IAccount, uint>(); // TODO: Remove this when repositories are implemented _accountsRepository.Create(_characterSpawn.Account); Logger.LogDone(); Logger.LogStart(">> Initializing spawn services"); SpawnXmlReader spawnXmlReader = new SpawnXmlReader(_monsterService, _npcService); ICollection <SpawnSource> spawnSources = (await spawnXmlReader.LoadAsync(Settings.Default.Spawns_Xml)).ToList(); _creatureSpawnService = new CreatureSpawnService(spawnSources); RegisterSpawns(spawnSources); // TODO: Remove this when player repositories are implemented; _creatureSpawnService.RegisterCreature(_characterSpawn); Logger.LogDone(); Logger.LogStart(">> Initializing communication services"); _chatService = new ChatService(_accountsRepository.GetAll(), channels); _commandService = new CommandService(); _commandService.Register(new TeleportCommand(_townService, _creatureSpawnService)); _commandService.Register(new TownListCommand(_townService)); _commandService.Register(new PositionInfoCommand()); _commandService.Register(new ChangeSexCommand()); _commandService.Register(new BroadcastCommand(_creatureSpawnService)); Logger.LogDone(); Logger.LogStart(">> Initializing game server"); _gameConnections = new List <GameConnection>(); _gameListener = new TcpListener(IPAddress.Any, Settings.Default.Network_Port_GameServer); _gameListener.Start(); _gameListener.BeginAcceptSocket(OnGameMessageReceived, _gameListener); Logger.LogDone(); Logger.LogStart(">> Initializing login server"); _loginConnections = new List <LoginConnection>(); _loginListener = new TcpListener(IPAddress.Any, Settings.Default.Network_Port_LoginServer); _loginListener.Start(); _loginListener.BeginAcceptSocket(OnLoginMessageReceived, _loginListener); Logger.LogDone(); _onlineTimer = new Stopwatch(); }
public Fight(MonsterService monsterService, WeaponsService weaponsService) { MonsterService = monsterService; WeaponsService = weaponsService; }
/// <summary> /// Initializes a new instance of the <see cref="SpawnXmlReader" /> class. /// </summary> /// <param name="monsterService">The monster service.</param> /// <param name="npcService">The NPC service.</param> public SpawnXmlReader(MonsterService monsterService, NpcService npcService) { _monsterService = monsterService; _npcService = npcService; }
public HuntMonter() { InitializeComponent(); ms = IOC.Resolve <MonsterService>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserService userService, LieutenantService lieutenantService, MonsterService monsterService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseCors("ApiPolicy"); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); // Load users IList <User> userList = userService.Get(); foreach (var user in userList) { user.Lieutenants = new List <Lieutenant>(); user.Monsters = new List <Monster>(); user.Character.CurrentHealth = 0; user.Character.CurrentStamina = 0; user.Character.HeroicFeatUsed = false; } GameHandler.Users = userList; IList <Lieutenant> lieutenants = lieutenantService.Get(); IList <Monster> monsters = monsterService.Get(); GameHandler.Lieutenants = lieutenants; GameHandler.Monsters = monsters; }
public async Task Solohunt(CommandContext ctx, int characterLevel, string monsterName, int perceptionBonus, int investigationBonus, int lastSkillBonus, string skillUsed) { if (characterLevel > 20 || characterLevel < 1) { await ctx.RespondAsync($"```Your character level should between 1 and 20```"); return; } MonsterService ms = new MonsterService(); var monster = ms.GetByName(monsterName); if (monster == null) { await ctx.RespondAsync($"```I don't know this monster sorry```"); return; } if (monster.CR > (decimal)this.soloHuntData[characterLevel].Item3) { await ctx.RespondAsync($"```solohunt is impossible Monster CR {monster.CR} is too high for you```"); return; } int difficulty = 0; int numberOfSucces = 0; Random roller = new Random(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"```"); //Calculate difficulty if (monster.CR == (decimal)this.soloHuntData[characterLevel].Item3) { difficulty = 6; } else if (monster.CR >= (decimal)this.soloHuntData[characterLevel].Item2 && monster.CR < (decimal)this.soloHuntData[characterLevel].Item3) { difficulty = 3; } decimal totalDC = monster.CR + difficulty; int roll = roller.Next(1, 21) + perceptionBonus; stringBuilder.AppendLine($"Perception check : {roll}"); if (roll >= totalDC) { numberOfSucces++; } roll = roller.Next(1, 21) + investigationBonus; stringBuilder.AppendLine($"Investigation check : {roll}"); if (roll >= totalDC) { numberOfSucces++; } roll = roller.Next(1, 21) + lastSkillBonus; stringBuilder.AppendLine($"{skillUsed} check : {roll}"); if (roll >= totalDC) { numberOfSucces++; } switch (numberOfSucces) { case 0: stringBuilder.AppendLine($"0 succes you paid 50g for hospital"); break; case 1: stringBuilder.AppendLine($"1 succes"); break; case 2: stringBuilder.AppendLine($"2 succes"); break; case 3: stringBuilder.AppendLine($"3 succes"); break; } stringBuilder.AppendLine($"```"); await ctx.RespondAsync(stringBuilder.ToString()); }
public MonsterServiceTests() { _mockMonsterRepository = new Mock <IMonsterRepository>(); fixture = new MonsterService(_mockMonsterRepository.Object, new Mock <ILogger <MonsterService> >().Object); }
public MonsterController(MonsterService monsterService) { _monsterService = monsterService; }