private int DrawBackground(ref XGraphics gfx, int start, int pageWidth, int pageHeight)
        {
            start += LINEHEIGHT;

            string exceptionality = _character !.Exceptionality switch
            {
                ExceptionalityType.Vlastnosti => "Vlastnosti",
                ExceptionalityType.Kombinovane => "Kombinované",
                ExceptionalityType.Zazemi => "Zázemí",
                _ => ""
            };



            DrawBonus(ref gfx, "Vyjímečnost:", exceptionality,
                      PADDING, start + LINEHEIGHT * 0);

            DrawBonus(ref gfx, "Původ:", _character.Origin,
                      PADDING, start + LINEHEIGHT * 1);

            DrawBonus(ref gfx, "Počát. peníze:", RuleTables.GetPresentableMoney(_character.StartMoneyValue),
                      PADDING, start + LINEHEIGHT * 2);

            RuleTables.GetStartSkills(_character.StartSkillGrade, _character.Profession,
                                      out int p, out int m, out int c);

            DrawBonus(ref gfx, "Dovednosti:", "Fyz.: " + p + "   Psy.: " + m + "   Kom.: " + c,
                      PADDING, start + LINEHEIGHT * 3);


            return(start + LINEHEIGHT * 4);
        }
Exemplo n.º 2
0
        public void UpdateDerivedValues()
        {
            int Sil = GetAttribute(AttributeCode.Sil);
            int Obr = GetAttribute(AttributeCode.Obr);
            int Zrc = GetAttribute(AttributeCode.Zrc);
            int Vol = GetAttribute(AttributeCode.Vol);
            int Int = GetAttribute(AttributeCode.Int);
            int Chr = GetAttribute(AttributeCode.Chr);


            DerivedAttributes[AttributeCode.Sms] = Zrc;                                                           //+Race.RacialAttributes[AttributeCode.Sms];
            DerivedAttributes[AttributeCode.Odl] = Sil;                                                           //+Race.RacialAttributes[AttributeCode.Odl];
            DerivedAttributes[AttributeCode.Vdr] = (Sil + Vol) / 2;                                               //+Race.RacialAttributes[AttributeCode.Vdr];
            DerivedAttributes[AttributeCode.Rch] = (Sil + Obr) / 2 + RuleTables.GetHeightCorrection(HeightBonus); //+Race.RacialAttributes[AttributeCode.Rch];

            Combat = (Obr + GetAttribute(Profession.CombatAttribute)) / 2 + RuleTables.GetHeightCorrection(HeightBonus);
            if (Profession.GetType() == typeof(Thief))
            {
                Combat += ((Thief)Profession).GetThiefSkillBonus("Periferní vidění");
            }
            Attack  = Obr / 2;
            Defense = (Obr + 1) / 2;
            Ranged  = Zrc / 2;

            WoundLimit   = DerivedAttributes[AttributeCode.Odl] + 10;
            FatigueLimit = DerivedAttributes[AttributeCode.Vdr] + 10;

            Beauty       = (Obr + Zrc) / 2 + Chr / 2;
            Dangerousnes = (Sil + Vol) / 2 + Chr / 2;
            Dignity      = (Int + Vol) / 2 + Chr / 2;
        }
Exemplo n.º 3
0
        private void CalculateAttributePointLimits(AttributeCode attribute, out int surePoints, out int variablePoints)
        {
            int MaxStart = IsMainAttribute(attribute) ? 3 : RuleTables.GetStartingMaxAttribute(Exceptionality);
            int MaxZv    = GetAttributeMax(attribute) - MaxStart;
            int Val      = BaseAttributes[attribute];

            surePoints     = Math.Max(Val - MaxStart, 0);
            variablePoints = Math.Min(MaxZv - surePoints, Val - (IsMainAttribute(attribute) ? 1 : 0));
        }
Exemplo n.º 4
0
        public int GetAttributeMax(AttributeCode attribute)
        {
            if (!BaseAttributes.ContainsKey(attribute))
            {
                throw new ArgumentOutOfRangeException("Tried to get nonexistent attribute.");
            }

            if (IsMainAttribute(attribute))
            {
                return(3 + (Level - 1) - ((Level - 1) / 3));
            }

            return(RuleTables.GetStartingMaxAttribute(Exceptionality) + (Level - 1) - (Level - 1) / 2);
        }
        private void DrawInventory()
        {
            IList <ItemCategory> items = _character !.GetInventoryCategories();

            PdfPage   page          = _document !.AddPage();
            XGraphics gfx           = XGraphics.FromPdfPage(page);
            int       currentHeight = PADDING_TOP;

            int pageWidth  = (int)page.Width.Point;
            int pageHeight = (int)page.Height.Point;

            gfx.DrawString("Vybavení", _fontTitle, XBrushes.Black,
                           new XPoint(PADDING, currentHeight));
            currentHeight += LINEHEIGHT + 10;

            DrawBonus(ref gfx, "Peníze:", RuleTables.GetPresentableMoney(_character.Money + _character.StartMoneyValue),
                      PADDING, currentHeight);

            currentHeight += LINEHEIGHT;

            foreach (ItemCategory category in items)
            {
                if (currentHeight + LINEHEIGHT * 4 > pageHeight - PADDING_TOP)
                {
                    page          = _document.AddPage();
                    gfx           = XGraphics.FromPdfPage(page);
                    currentHeight = PADDING_TOP;
                }

                currentHeight += LINEHEIGHT * 1;
                gfx.DrawString(category.CategoryName, _fontBonus, XBrushes.Black,
                               new XPoint(PADDING, currentHeight));
                currentHeight += LINEHEIGHT * 2;

                foreach (IItem item in category.Items)
                {
                    if (currentHeight + LINEHEIGHT * GetItemLines(item) > pageHeight - PADDING_TOP)
                    {
                        page          = _document.AddPage();
                        gfx           = XGraphics.FromPdfPage(page);
                        currentHeight = PADDING_TOP;
                    }

                    currentHeight = DrawItem(ref gfx, item, currentHeight, pageWidth, pageHeight);
                }
            }
        }
        private int DrawItem(ref XGraphics gfx, IItem item, int start, int pageWidth, int pageHeight)
        {
            DrawBonus(ref gfx, "Pŕedmět:", item.Name,
                      PADDING, start + LINEHEIGHT * 0);

            DrawBonus(ref gfx, "Cena/ks:", RuleTables.GetPresentableMoney(item.Price),
                      PADDING, start + LINEHEIGHT * 1);
            DrawBonus(ref gfx, "Váha:", item.Weight + " kg",
                      pageWidth / 2, start + LINEHEIGHT * 1);
            DrawBonus(ref gfx, "Počet:", item.Count.ToString(),
                      PADDING, start + LINEHEIGHT * 2);
            DrawBonus(ref gfx, "Pravidla:", item.Source.ToString(),
                      pageWidth / 2, start + LINEHEIGHT * 2);

            start = DrawWeapon(ref gfx, item, start + LINEHEIGHT * 3, pageWidth, pageHeight);

            return(start + LINEHEIGHT * 1);
        }
Exemplo n.º 7
0
        public IList <Information> ValidateStartingCharacter()
        {
            IList <Information> problems = new List <Information>();

            if (Name == "")
            {
                problems.Add(new Information("Jméno", "Postava potřebuje jméno k tomu aby byla validní.\n\nNezapomeň, že jméno je jen označení postavy. Pokud tvoje postava nezná svoje jméno, má asi nějaký způsob jak se označuje, buď ona sama, nebo ostatními kolem ní. Ale každá postava by měla mít své označení, byť by to bylo \"Bezejmený\""));
            }

            int currentMoney = Money + StartMoneyValue;

            if (currentMoney < 0)
            {
                problems.Add(new Information("Peníze", "Byli přesaženy peníze o " + RuleTables.GetPresentableMoney(-currentMoney) + ".\n\nAby mohla být postava uzavřena je potřeba nepřesáhnout peníze získané ze zázemí postavy. Buď odeberte některé předměty nebo zvyšte počáteční peníze postavy."));
            }

            int backgroundPoints = BackroundPoints - OriginGrade - StartMoneyGrade - StartSkillGrade;

            if (backgroundPoints < 0)
            {
                problems.Add(new Information("Zázemí", "Byl přesažen počet využitých bodů zázemí. Bylo použito o " + (-backgroundPoints) + " bodů více.\n\nSniž počet využitých bodů, nebo zvyš počet dostupných bodů skrze vyjímečnost, pokud je to možné."));
            }
            else if (backgroundPoints > 0)
            {
                problems.Add(new Information("Zázemí", "Máš " + backgroundPoints + " nevyužitých bodů zázemí.\n\nZvyš jednu z kategorií zázemí, nebo sniž počet dostupných bodů skrze vyjímečnost, pokud je to možné."));
            }

            int freeMainAtt = FreeMainAttributePoints;

            if (freeMainAtt != 0)
            {
                string mainAttMsg = "";
                if (freeMainAtt < 0)
                {
                    mainAttMsg = "Přesáhl jsi o " + (-freeMainAtt) + " body hlavních vlastností. Aby postava byla validní je potřeba aby využila přesně její body hlavních vlastností.";
                }
                else if (freeMainAtt > 0)
                {
                    mainAttMsg = "Máš " + freeMainAtt + " nevyužitých bodů hlavních vlastností. Aby postava byla validní je potřeba aby využila všechny její body hlavních vlastností.";
                }

                problems.Add(new Information("Hlavní vlastnosti", mainAttMsg));
            }

            int freeMinorAtt = FreeMinorAttributePoints;

            if (freeMinorAtt != 0)
            {
                string minorAttMsg = "";
                if (freeMinorAtt < 0)
                {
                    minorAttMsg = "Přesáhl jsi o " + (-freeMinorAtt) + " body vedlejších vlastností. Aby postava byla validní je potřeba aby využila přesně její body vedlejších vlastností.";
                }
                else if (freeMinorAtt > 0)
                {
                    minorAttMsg = "Máš " + freeMinorAtt + " nevyužitých bodů vedlejších vlastností. Aby postava byla validní je potřeba aby využila všechny její body vedlejších vlastností.";
                }

                problems.Add(new Information("Vedlejší vlastnosti", minorAttMsg));
            }


            //dovednosti
            if (Level == 1)
            {
                int phy, men, com;
                phy = FreeStartingSkillPoints(SkillType.Fyzicka);
                men = FreeStartingSkillPoints(SkillType.Psychicka);
                com = FreeStartingSkillPoints(SkillType.Kombinovana);

                string skillPointList = "";

                if (phy < 0)
                {
                    skillPointList += "\nFyzické dovednosti přesáhnuty o " + (-phy) + " bodů.";
                }
                else if (phy > 0)
                {
                    skillPointList += "\nFyzické dovednosti mají " + phy + " nevyužitých bodů.";
                }
                if (men < 0)
                {
                    skillPointList += "\nPsychické dovednosti přesáhnuty o " + (-men) + " bodů.";
                }
                else if (men > 0)
                {
                    skillPointList += "\nPsychické dovednosti mají " + men + " nevyužitých bodů.";
                }
                if (com < 0)
                {
                    skillPointList += "\nKombinované dovednosti přesáhnuty o " + (-com) + " bodů.";
                }
                else if (com > 0)
                {
                    skillPointList += "\nKombinované dovednosti mají " + com + " nevyužitých bodů.";
                }

                string joke = "";
                if (men < 0 && GetSkillRating("Čtení / psaní") > 0)
                {
                    joke = "\nTřeba se můžeš zbavit dovednosti Čtení/psaní. Kdo by to potřeboval? A navíc knihy jsou děsně drahý, ty si jako chudý dobrodruch stejně nebudeš moct dovolit. To se radši nauč ohánět s pořádným kyjem. Ten je levnej, neničíš si oči když ho používáš ve tmě či za šera a navíc tím můžeš uspat toho otravného kněze co se ti neustále snaží prokecat díru do hlavy.";
                }

                if (skillPointList != "")
                {
                    problems.Add(new Information("Dovednosti", "Špatně využity body dovedností. Pro validitu postavy je potřeba využít všechny počáteční body dovedností.\n"
                                                 + skillPointList + "\n\nUprav naučené dovednosti, nebo změň míru počátečních dovedností ze zázemí." + joke));
                }
            }
            else
            {
                int    max     = GetMaxSkillPoints();
                int    current = SkillPoints.Aggregate(0, (result, x) => result + x.Value);
                string msg     = "";

                int phy, men, com;
                phy = SkillPoints[SkillType.Fyzicka];
                men = SkillPoints[SkillType.Psychicka];
                com = SkillPoints[SkillType.Kombinovana];

                GetSkillPointLimits(SkillType.Fyzicka, out int surePointsPhy, out int variablePointsPhy);
                GetSkillPointLimits(SkillType.Psychicka, out int surePointsMen, out int variablePointsMen);
                GetSkillPointLimits(SkillType.Kombinovana, out int surePointsCom, out int variablePointsCom);

                if (max + current > 0)
                {
                    msg += "\nSoučet všech využitých bodů dovedností byl přesažen o " + (-(max + current)) + " bodů.";
                }
                else if (max + current < 0)
                {
                    msg += "\nSoučet všech využitých bodů dovedností není dostatečný a zbývají " + (max + current) + " bodů dovedností.";
                }

                if (phy + surePointsPhy > 0)
                {
                    msg += "\nZbývá " + (phy + surePointsPhy) + " jistých fyzických dovednostních bodů.";
                }
                else if (phy + variablePointsPhy < 0)
                {
                    msg += "\nNejisté fyzické dovednostní body byli přesaženy o " + (-(phy + variablePointsPhy)) + " bodů.";
                }
                if (men + surePointsMen > 0)
                {
                    msg += "\nZbývá " + (men + surePointsMen) + " jistých psychických dovednostních bodů.";
                }
                else if (men + variablePointsPhy < 0)
                {
                    msg += "\nNejisté psychických dovednostní body byli přesaženy o " + (-(men + variablePointsMen)) + " bodů.";
                }
                if (com + surePointsCom > 0)
                {
                    msg += "\nZbývá " + (com + surePointsCom) + " jistých kombinovaných dovednostních bodů.";
                }
                else if (com + variablePointsCom < 0)
                {
                    msg += "\nNejisté kombinovaných dovednostní body byli přesaženy o " + (-(com + variablePointsCom)) + " bodů.";
                }


                if (msg != "")
                {
                    problems.Add(new Information("Dovednosti", "Špatně využity body dovedností. Pro validitu postavy je potřeba využít všechny jisté body dovedností, nesmí se přesáhnout omezení z nejistých bodů dovedností a musí být plně využit součet všech bodů dovedností.\n"
                                                 + msg + "\n\nUprav naučené dovednosti, rozdělení vlastností, úroveň postavy nebo změň míru počátečních dovedností ze zázemí."));
                }
            }

            Profession.IsValid(this, ref problems);


            return(problems);
        }
Exemplo n.º 8
0
        public InventoryCreatorViewModel(Character createdCharacter) : base(createdCharacter)
        {
            ShowAddItemDialog    = new Interaction <AddItemViewModel, ItemDataViewModel?>();
            ShowRemoveItemDialog = new Interaction <ConfirmationViewModel, ResultViewModel?>();
            ShowMessageBox       = new Interaction <MessageBoxViewModel, ResultViewModel?>();
            _equipmentItems      = new ObservableCollection <ItemCategory>(createdCharacter.GetInventoryCategories());

            AddItemCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                AddItemViewModel aivm = new AddItemViewModel(CharacterIsClosed);

                ViewModelMessenger.Register(aivm);

                ItemDataViewModel?result = await ShowAddItemDialog.Handle(aivm);

                if (result != null && result.Item != null)
                {
                    IItem itemInstance = result.Item.NewPriceInstance(result.BuyingPrice, result.Count);
                    if (createdCharacter.AddItem(itemInstance, result.IsBuying ? result.BuyingPrice : 0))
                    {
                        AddItemToDisplay(itemInstance);
                        SelectedItem = itemInstance;
                        NotifyEverything();
                        //NotifySingle(this, nameof(DisplayMoney));
                        NotifyOthers(this, "WeaponCombinations");
                    }
                    else
                    {
                        //Window mainWindow = ((IVisual)this).FindAncestorOfType<Window>();
                        //await MessageBox.Show(null, "Postava nemá dostatek peněz na koupi. Chybí " + (result.BuyingPrice - createdCharacter.Money) + ".", "Nedostatek peněz", MessageBox.MessageBoxButtons.Ok);
                        string message = "Postava nemá dostatek peněz na koupi předmětu\"" + result.Item.Name + "\". Chybí " + RuleTables.GetPresentableMoney(result.BuyingPrice - createdCharacter.Money) + ".";
                        var messageBoxStandardWindow = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow("Nedostatek peněz", message);
                        await messageBoxStandardWindow.Show();
                    }
                }

                ViewModelMessenger.Unregister(aivm);
            });

            RemoveItemCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (SelectedItem != null)
                {
                    ConfirmationViewModel cnf_vm = new ConfirmationViewModel("Smazat předmět?", "smazat předmět " + SelectedItem.Name);

                    ViewModelMessenger.Register(cnf_vm);

                    ResultViewModel?result = await ShowRemoveItemDialog.Handle(cnf_vm);

                    if (result != null && result.Value)
                    {
                        int sellPrice = createdCharacter.CharacterIsClosed ? 0 : (SelectedItem.Price == null ? 0 : (int)SelectedItem.Price);
                        createdCharacter.RemoveItem(SelectedItem, sellPrice);
                        RemoveItemFromDisplay(SelectedItem);
                        SelectedItem = null;
                        //NotifySingle(this, nameof(DisplayMoney));
                        NotifyEverything();
                        NotifyOthers(this, "WeaponCombinations");
                    }

                    ViewModelMessenger.Unregister(cnf_vm);
                }
            });
        }