private void NewPlayer(LevelRootViewModel levelRoot, CharacterViewModel player)
    {
        player.IsAliveProperty
            .Where(isAlive => isAlive == false)
            .Subscribe(_ => this.ExecuteCommand(levelRoot.LoseGame))
            .DisposeWhenChanged(levelRoot.PlayerProperty);

        player.FinishReached.Subscribe(_ => this.ExecuteCommand(levelRoot.WinGame));
    }
Exemplo n.º 2
0
 private void _compendium_CharacterChanged(object sender, CompendiumChangeEventArgs e)
 {
     if (_selectedCharacter != null && e.IDs.Contains(_selectedCharacter.CharacterModel.Id))
     {
         _selectedCharacter = new CharacterViewModel(_selectedCharacter.CharacterModel);
     }
     foreach (CharacterListItemViewModel listItem in _characters)
     {
         if (e.IDs.Contains(listItem.CharacterModel.Id))
         {
             listItem.UpdateModel(listItem.CharacterModel);
         }
     }
 }
Exemplo n.º 3
0
 public IActionResult Create(string game, [FromBody] CharacterCreationObject premade, bool includeSkills)
 {
     _logger.Log("In create with parameter " + premade.Name);
     try
     {
         var myCharac = _service.Create(game, premade, includeSkills);
         var response = new CharacterViewModel(myCharac);
         return(Ok(response));
     }catch (Exception ex)
     {
         _logger.Log("Error in character creation process : " + ex.Message + Environment.NewLine + ex.InnerException);
         return(BadRequest());
     }
 }
Exemplo n.º 4
0
        public static CharacterViewModel ConvertToViewModel(string characterName, Dictionary <int, string> books = null)
        {
            var viewModel = new CharacterViewModel
            {
                CharacterName = characterName
            };

            if (books != null)
            {
                viewModel.Books = new SortedDictionary <int, string>(books);
            }

            return(viewModel);
        }
Exemplo n.º 5
0
        public CharacterViewModel CreateCharacter(CharacterViewModel viewModel)
        {
            var character = Mapper.Map <CharacterViewModel, Character>(viewModel);

            if (_dndRepository.GetSingle <Character>(a => a.Id == viewModel.Id, true) != null)
            {
                throw new Exception(string.Format(Resources.ValidationMessages.EntityM_Error_AlredyExist, nameof(Character)));
            }
            _dndRepository.Add(character);

            _dndRepository.Commit();
            character = _dndRepository.GetSingle <Character>(a => a.Id == character.Id, false, a => a.Aligment);
            return(Mapper.Map <Character, CharacterViewModel>(character));
        }
        public static CharacterViewModel ConvertToviewModel(Character dbModel)
        {
            var viewModel = new CharacterViewModel
            {
                CharacterName = dbModel.CharacterName
            };

            foreach (var book in dbModel.BookCharacter)
            {
                viewModel.Books.Add(book.Book.BookName ?? string.Empty);
            }

            return(viewModel);
        }
Exemplo n.º 7
0
        public ActionResult CreatePlayer(CharacterViewModel model)
        {
            string name         = model.Name;
            int    strength     = model.Strength;
            int    dexterity    = model.Dexterity;
            int    intelligence = model.Intelligence;
            Gender gender       = model.Gender;
            Race   race         = model.Race;

            Models.Class c = model.Class;
            switch (race)
            {
            case Race.Cat:
                strength     = 8;
                dexterity    = 8;
                intelligence = 5;
                break;

            case Race.Dog:
                strength     = 8;
                dexterity    = 5;
                intelligence = 8;
                break;

            case Race.Fish:
                strength     = 3;
                dexterity    = 10;
                intelligence = 8;
                break;

            case Race.Bird:
                strength     = 4;
                dexterity    = 7;
                intelligence = 10;
                break;

            case Race.Horse:
                strength     = 10;
                dexterity    = 6;
                intelligence = 5;
                break;
            }
            Player p      = new Player(name, gender, race, c.ToString(), strength, dexterity, intelligence);
            var    repo   = new PlayerRepository(new PlayerSQLContext());
            Player player = repo.Insert(p);

            playerId = player.Id;
            return(RedirectToAction("Play", "Game", new { id = player.Id }));
        }
Exemplo n.º 8
0
        public IActionResult CreateNewCharacter()
        {
            var newCharacter = new CharacterViewModel();

            ViewData["Characters"]       = charactersRepository.GetAllCharacters().ToDictionary(ch => ch.Id, ch => ch.Name + " " + ch.Surname);
            ViewData["TypeOfCharacters"] = charactersRepository.GetTypesOfCharacter().ToDictionary(b => b.Id, b => b.Name);;
            ViewData["Orientations"]     = charactersRepository.GetOrientations().ToDictionary(b => b.Id, b => b.Name);;
            ViewData["AlignmentCharts"]  = charactersRepository.GetAlignmentChatrs().ToDictionary(b => b.Id, b => b.Name);
            ViewData["Breeds"]           = charactersRepository.GetAllBreeds().ToDictionary(b => b.Id, b => b.Name);
            ViewData["DisableEditing"]   = "false";

            HttpContext.Session.SetComplexData("NewRelationships", newCharacter.Relationships);

            return(View("~/Views/Character/CharacterView.cshtml", newCharacter));;
        }
Exemplo n.º 9
0
        public Character Edit(CharacterViewModel newVersion, Character oldversion, string contextName)
        {
            var _game = _games.SingleOrDefault(g => g.HasName(contextName));

            _game.SetCaracteristicFromCaracteristicViewModel(oldversion.BaseAttributes, newVersion.BaseAttributes);

            //rewrite method chosenskills to accept a list of carac instead of a charactercreationobject
            _game.SetChosenSkills(newVersion.Skills, oldversion);

            //_game.SetCaracteristicFromCaracteristicViewModel(oldversion.Skills, newVersion.Skills);
            _game.SetDefaultStats(oldversion);
            //_game.SetDefaultSpendablePoints(oldversion);

            return(oldversion);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Character(string id)
        {
            var response = await _finalSpaceClient.GetSingleCharacter(id);

            var viewModel = new CharacterViewModel();

            viewModel.Abilities = response.abilities;
            viewModel.Id        = response.id;
            viewModel.Species   = response.species;
            viewModel.Status    = response.status;
            viewModel.ImageUrl  = response.img_url;
            viewModel.Name      = response.name;

            return(View(viewModel));
        }
Exemplo n.º 11
0
        static public CharacterViewModel ToCharVM(Character c)
        {
            var cvm = new CharacterViewModel()
            {
                Id             = c.Id,
                Name           = c.Name,
                CharacterModel = c.CharacterModel,
                Hp             = c.Hp,
                Hunger         = c.Hunger,
                Hydration      = c.Hydration,
                Level          = c.Level
            };

            return(cvm);
        }
 public MainViewModel()
 {
     LoginConfig.Instance.Load();
     Proxy = new DofusRetroProxy(LoginConfig.Instance.PathDofus, new Account()
     {
         Username = LoginConfig.Instance.Username, Password = LoginConfig.Instance.Password
     });
     InteractivObject.Initialize();
     Map.Initialize();
     Spell.Initialize();
     _CharacterViewModel  = new CharacterViewModel(Proxy.Account.Character.Characteristics, Proxy.Account);
     _InventoryViewModel  = new InventoryViewModel(Proxy.Account);
     _MagicForgeViewModel = new MagicForgeViewModel(Proxy.Account);
     Navigate(_CharacterViewModel);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Load the page where the user can see all of the character linked to his userid.
        /// </summary>
        /// <param name="loginView"></param>
        /// <returns></returns>
        public ActionResult Character(UserLoginViewModel loginView)
        {
            //Add characters from the logged in users to a view
            if (loginView != null)
            {
                Session["UserID"] = loginView.UserID;
            }
            RPGRepository rpgrepo = new RPGRepository(rpgct);

            _charViewModel = new CharacterViewModel
            {
                Characters = rpgrepo.GetCharactersFromUser(loginView.UserID)
            };
            _loginview = loginView;
            return(View(_charViewModel));
        }
        protected virtual void OnCharacterUpdated(CharacterViewModelProviderEventArgs args)
        {
            CharacterViewModel @char = _vmCache.FirstOrDefault(model => args.OldMetadata.Equals(model.Metadata));

            if (@char != null)
            {
                @char.Metadata = args.NewMetadata ?? args.OldMetadata;
            }

            CharacterProviderDelegate handler = CharacterUpdated;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        public async Task <IActionResult> Detail(int Id)
        {
            try
            {
                Character character = await _characterServices.GetCharacterAsync(Id);

                CharacterViewModel userModel = CharacterMapper.MapCharacter(character);

                return(View("Detail", userModel));
            }
            catch (GlobalException e)
            {
                //TODO
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 16
0
        public IActionResult GetAll(string game)
        {
            _logger.Log("In Fallout Controller GetAll with arg " + game);

            var allCharac = _service.Get(game);

            List <CharacterViewModel> allDto = new List <CharacterViewModel>();

            foreach (var charac in allCharac)
            {
                CharacterViewModel dto = new CharacterViewModel(charac);
                allDto.Add(dto);
            }

            return(Ok(allDto));
        }
Exemplo n.º 17
0
        public IActionResult Create(Character character)
        {
            try
            {
                ThrowIfInvalidParams(character);

                var character1 = _characterRepository.create(character);
                CharacterViewModel characterViewModel = new CharacterViewModel(character1);
                return(View("create", characterViewModel));
            }
            catch (Exception e)
            {
                CharacterViewModel characterViewModel = new CharacterViewModel(e.Message);
                return(View("create", characterViewModel));
            }
        }
Exemplo n.º 18
0
        public IActionResult GetCharacterById(int id)
        {
            var vm = new CharacterViewModel();

            try
            {
                vm = _characterLoginHandler.GetCharacterById(id);
            }
            catch (Exception ex)
            {
                _responseFormatter.SetError(ex);
                return(new BadRequestObjectResult(_responseFormatter.GetResponse()));
            }
            _responseFormatter.Add("character", vm);
            return(new OkObjectResult(_responseFormatter.GetResponse()));
        }
Exemplo n.º 19
0
        public IActionResult CreateRandomly(string game, [FromBody] RandomCharacterCreationObject charac)
        {
            if (charac == null)
            {
                charac = new RandomCharacterCreationObject();
            }

            _logger.Log("In create randomly with parameter " + charac.Name);

            //charac.GameName = game;

            var myCharac = _service.CreateRandomly(game, charac);
            var response = new CharacterViewModel(myCharac);

            return(Ok(response));
        }
Exemplo n.º 20
0
        public ActionResult Character(string name, string realm)
        {
            int roster = 1;

            // Calculate the UrlReferrer link, for a return Url
            if (System.Web.HttpContext.Current.Request.UrlReferrer != null)
            {
                if (!string.IsNullOrWhiteSpace(name))
                {
                    ViewBag.Name = name;
                }

                if (System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Contains("/Guild"))
                {
                    ViewBag.ReturnUrl = "/WGO/Guild";
                    ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Substring(System.Web.HttpContext.Current.Request.UrlReferrer.ToString().IndexOf("/WGO"));
                    roster            = 1;
                }
                else if (System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Contains("/Raid"))
                {
                    ViewBag.ReturnUrl = "/WGO/Raid";
                    ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Substring(System.Web.HttpContext.Current.Request.UrlReferrer.ToString().IndexOf("/WGO"));
                    roster            = 2;
                }
                else if (System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Contains("/MyRoster"))
                {
                    ViewBag.ReturnUrl = "/WGO/MyRoster";
                    ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.ToString().Substring(System.Web.HttpContext.Current.Request.UrlReferrer.ToString().IndexOf("/WGO"));
                    roster            = 3;
                }
            }

            // Get the Character info
            CharacterViewModel model = new CharacterViewModel();

            model.Character = null;
            var chars = db.Characters.Where(s => s.Name == name && s.Realm == realm && s.Roster == roster);

            if (chars.Any())
            {
                // Store the Character data
                model.Character = chars.First();
                model.AuditHtml = this.CalculateAuditHtml(model.Character);
            }

            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("Character, SelectedSpeciesId")] CharacterViewModel characterViewModel)
        {
            if (ModelState.IsValid)
            {
                var selectedSpecies = await _speciesService.GetByIdAsync(characterViewModel.SelectedSpeciesId);

                characterViewModel.Character.Species = selectedSpecies;

                await _characterService.CreateAsync(characterViewModel.Character);

                return(RedirectToAction(nameof(Index)));
            }

            characterViewModel.Species = await _speciesService.GetAsync();

            return(View(characterViewModel));
        }
        public async Task <IActionResult> EditCharacter(CharacterViewModel viewModel)
        {
            try
            {
                Character mapCharacterToCharacter = CharacterMapper.MapCharacter(viewModel);
                Character character = await _characterServices.EditCharacterAsync(mapCharacterToCharacter);

                CharacterViewModel mapCharacter = CharacterMapper.MapCharacter(character);

                return(View("Detail", mapCharacter));
            }
            catch (GlobalException e)
            {
                //TODO
                return(BadRequest(e.Message));
            }
        }
        public ActionResult AddCharacterToDb(CharacterViewModel character)
        {
            var characterDataModel = this.factory.CreateCharacter();

            characterDataModel.Name                 = character.Name;
            characterDataModel.Description          = character.Description;
            characterDataModel.Image                = character.Image;
            characterDataModel.isDeleted            = false;
            characterDataModel.CreatedOn            = DateTime.Now;
            characterDataModel.AbilitiesDesctiption = character.AbilitiesDesctiption;
            characterDataModel.Origin               = character.Origin;
            characterDataModel.Powers               = character.Powers;

            this.service.AddCharacter(characterDataModel);

            return(RedirectToAction("AddCharacter"));
        }
Exemplo n.º 24
0
        private void DataGridPasteCommand_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            DataGrid dg = sender as DataGrid;

            if (dg == null)
            {
                return;
            }
            CharacterViewModel model = dg.DataContext as CharacterViewModel;

            if (model == null)
            {
                return;
            }
            ClipboardHelper.SetAttributesString(Clipboard.GetText(), model.Character);
            e.Handled = true;
        }
        private void FSWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            CharacterFile cf = CharacterFile.Load(e.FullPath);

            if (cf == null)
            {
                return;
            }
            CharacterViewModel viewmodel = CreateViewModel(cf, e.FullPath);

            if (_lastCreated != null && e.FullPath.Equals(_lastCreated))
            {
                _lastCreated = null;
                OnCharacterAdded(new CharacterViewModelProviderEventArgs(viewmodel));
                return;
            }
            OnCharacterUpdated(new CharacterViewModelProviderEventArgs(viewmodel, e.FullPath));
        }
Exemplo n.º 26
0
        public IActionResult Save(CharacterViewModel characterViewModel)
        {
            var mapper = new MappingProfile();

            characterViewModel.Relationships.AddRange(HttpContext.Session.GetComplexData <List <RelationshipViewModel> >("NewRelationships"));
            var character = Mapper.Map <Character>(characterViewModel);

            if (characterViewModel.Id == 0)
            {
                charactersRepository.AddCharacter(character);
            }
            else
            {
                charactersRepository.UpdateCharacter(character);
            }

            return(Redirect($"/Home/CharacterView?characterId={character.Id}"));
        }
Exemplo n.º 27
0
        public JsonResult GetCharactersById(string characterId)
        {
            var model = new CharacterViewModel();

            var client = new MarvelClient();

            var characters = client.FindCharacters(new Dictionary <string, string>()
            {
                { "id", characterId }
            });

            if (characters.Any())
            {
                model = characters.Select(x => (CharacterViewModel)x).FirstOrDefault();
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        private void SaveViewModel(CharacterViewModel model)
        {
            FileStream fs = null;

            try
            {
                // Disable Watchers Temporarily
                _fsWatchers.ForEach(watcher => watcher.EnableRaisingEvents = false);
                //_fsWatcher.EnableRaisingEvents = false;
                fs = new FileStream(model.Metadata as string, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1024 * 16);

                // Card Bytes
                fs.Write(model.Character.CardBytes, 0, model.Character.CardBytes.Length);
                // Data Bytes
                fs.Write(model.Character.DataBytes, 0, model.Character.DataBytes.Length);
                // Thumb Lenght
                fs.Write(BitConverter.GetBytes(model.Character.ThumbBytes.Length), 0, 4);
                // Thumb Bytes
                fs.Write(model.Character.ThumbBytes, 0, model.Character.ThumbBytes.Length);
                // Variable-sized remainder can be appended to the thumb (used by tools like AAU override asset blobs)
                fs.Write(model.Character.RawBytes, 0, model.Character.RawBytes.Length);
                int lastBytes = model.Character.ThumbBytes.Length + 4 + model.Character.DataBytes.Length + model.Character.RawBytes.Length + 4;
                // Identifier Mark
                fs.Write(BitConverter.GetBytes(lastBytes), 0, 4);
                // Make Sure Flushed
                fs.Flush();


                model.Character.DataChanges  = false;
                model.Character.CardChanges  = false;
                model.Character.ThumbChanges = false;
            }
            catch
            { }
            finally
            {
                //Close Stream and ReEnable Watchers
                if (fs != null)
                {
                    fs.Close();
                }
                _fsWatchers.ForEach(watcher => watcher.EnableRaisingEvents = true);
            }
        }
Exemplo n.º 29
0
            private string[] GetPropertyString(CharacterViewModel model)
            {
                string oldPath = model.Metadata as string;
                string oldName = Path.GetFileNameWithoutExtension(oldPath);

                return(Properties.Select
                           (s =>
                {
                    if (s.Equals("$"))
                    {
                        return oldName;
                    }
                    DataBlockWrapper db = model.Character.CharAttributes[s];
                    return ParseEnum && db.IsEnum
                            ? db.EnumValue
                            : db.Value.ToString();
                })
                       .ToArray());
            }
Exemplo n.º 30
0
        public override void Modify(CharacterViewModel model)
        {
            Layer  thumbLayer  = CardGenerator.GenerateThumbnail(model.Character);
            Bitmap thumbBitmap = CardGenerator.Resample(thumbLayer, 74, 90, InterpolationMode.HighQualityBicubic);

            Layer cardLayer = CardGenerator.GenerateCard(model.Character);

            Bitmap cardBitmap = CardGenerator.Resample(cardLayer, 200, 300, InterpolationMode.Bilinear);

            MemoryStream streamThumb = new MemoryStream();

            thumbBitmap.Save(streamThumb, ImageFormat.Png);
            model.Character.SetThumbnail(streamThumb.ToArray());

            MemoryStream streamCard = new MemoryStream();

            cardBitmap.Save(streamCard, ImageFormat.Png);
            model.Character.SetCard(streamCard.ToArray());
        }
Exemplo n.º 31
0
        public static Character ToDbCharacterModel(CharacterViewModel vm)
        {
            Character dbCharacter = null;

            if (vm != null)
            {
                dbCharacter = new Character()
                {
                    Id          = vm.Id,
                    CampaignId  = vm.CampaignId,
                    Name        = String.IsNullOrWhiteSpace(vm.Name) ? String.Empty : vm.Name.Trim(),
                    Description = String.IsNullOrWhiteSpace(vm.CharDescription) ? String.Empty : vm.CharDescription.Trim(),
                    Notes       = String.IsNullOrWhiteSpace(vm.Notes) ? String.Empty : vm.Notes.Trim(),
                    // Add session conversion too?
                };
            }

            return(dbCharacter);
        }
    public override void Hit(CharacterViewModel character)
    {
        if (character.IsInvulnarable) return;
        character.Lives--;

        if (character.Lives <= 0)
        {
            character.IsAlive = false;
        }
        else
        {
            character.IsInvulnarable = true;
            Observable.Timer(TimeSpan.FromMilliseconds(1500))
                .Subscribe(l =>
                {
                    character.IsInvulnarable = false;
                });
        }
    }
    private void JumpStateChanged(CharacterViewModel character, Invert.StateMachine.State state)
    {
        if (state is NoJump)
        {
            character.JumpsPerformed = 0;
        }
        else if (state is DoJump)
        {
            character.JumpsPerformed++;
            character.JumpLocked = true;

            Observable
                .Timer(TimeSpan.FromMilliseconds(100))
                .Subscribe(l =>
                {
                    character.JumpLocked = false;
                });

        }
    }
 public virtual void FinishReached(CharacterViewModel character)
 {
 }
 public virtual void Hit(CharacterViewModel character)
 {
 }
 public abstract void InitializeCharacter(CharacterViewModel character);
 public virtual void PickUpCoin(CharacterViewModel character)
 {
 }
 public override void PickUpCoin(CharacterViewModel character)
 {
     base.PickUpCoin(character);
     character.CoinsCollected++;
 }
 public override void InitializeCharacter(CharacterViewModel character)
 {
     character.JumpStateProperty.Subscribe(state => JumpStateChanged(character, state));
 }
Exemplo n.º 40
0
 private async Task CharacterSelected(CharacterViewModel character)
 {
     var dialog = new MessageDialog(string.Format("{0} selected.", character.Name), "Character Selected");
     await dialog.ShowAsync();
 }