public void ShouldReturnJsonObject() { //arrange string raceJson = "\"race\":\"Human\""; string classJson = "\"class\":\"Wizard\""; string attributeSetJson = "\"characterAttributes\":[" + "{\"characterAttribute\":\"STR\",\"value\":0}," + "{\"characterAttribute\":\"CON\",\"value\":0}," + "{\"characterAttribute\":\"INT\",\"value\":0}," + "{\"characterAttribute\":\"WIS\",\"value\":0}," + "{\"characterAttribute\":\"CHR\",\"value\":0}," + "{\"characterAttribute\":\"DEX\",\"value\":10}," + "]"; IAttributeSet attributeSet = new EmptyAttributeSet(); _characterSheet = new CharacterSheet(new Wizard(), new Human(), attributeSet); string proficienciesJson = $"\"Proficiencies\":[{string.Join(",", _characterSheet.Proficiencies().Select(x => $"\"{x}\""))}],"; string expectedJson = $"{{characterSheet:{{{raceJson},{classJson},{ attributeSetJson},{proficienciesJson}}}}}"; attributeSet.SetAttribute(CharacterAttributeName.Dexterity, new AttributeScore(10)); StringBuilder sb = new StringBuilder(); //act _characterSheet.AddJsonToStringbuilder(sb); //assert sb.ToString().Should().Be(expectedJson); }
public void ShouldShouldReturnProficienciesForDwarfFighter() { //assign _characterSheet = new CharacterSheet(new Fighter(), new HillDwarf(), _attributeSet); List <IProficiency> expectedProficiencies = new List <IProficiency> { new Battleaxe(), new Handaxe(), new ThrowingHammer(), new Warhammer(), new BrewersSupplies(), new MasonsTools(), new SmithsTools(), new SimpleWeapons(), new MartialWeapons(), new AllArmor(), new AllShields() }; //act List <IProficiency> actualProficiencies = _characterSheet.Proficiencies(); //assert actualProficiencies.All(i => expectedProficiencies.Contains(i)).Should().BeTrue(); }
public void ShouldShouldReturnProficienciesForDwarfWizard() { //assign _characterSheet = new CharacterSheet(new Wizard(), new HillDwarf(), _attributeSet); List <IProficiency> expectedProficiencies = new List <IProficiency> { new Battleaxe(), new Handaxe(), new ThrowingHammer(), new Warhammer(), new BrewersSupplies(), new MasonsTools(), new SmithsTools(), new Dagger(), new Darts(), new Sling(), new Quarterstaff(), new LightCrossbow() }; //act List <IProficiency> actualProficiencies = _characterSheet.Proficiencies(); //assert actualProficiencies.All(i => expectedProficiencies.Contains(i)).Should().BeTrue(); }
public TextFormatter() { On <SetContextEvent>(e => { var assets = Resolve <IAssetManager>(); var state = Resolve <IGameState>(); var asset = e.AssetType switch { AssetType.PartyMember => (object)state.GetPartyMember((PartyCharacterId)e.AssetId), AssetType.Npc => state.GetNpc((NpcCharacterId)e.AssetId), AssetType.Monster => assets.LoadMonster((MonsterCharacterId)e.AssetId), AssetType.ItemList => assets.LoadItem((ItemId)e.AssetId), _ => null }; switch (e.Type) { case ContextType.Leader: _leader = (ICharacterSheet)asset; break; case ContextType.Subject: _subject = (ICharacterSheet)asset; break; case ContextType.Inventory: _inventory = (ICharacterSheet)asset; break; case ContextType.Combatant: _combatant = (ICharacterSheet)asset; break; case ContextType.Victim: _victim = (ICharacterSheet)asset; break; case ContextType.Weapon: _weapon = (ItemData)asset; break; } }); }
public TextFormatter() { On <SetContextEvent>(e => { var assets = Resolve <IAssetManager>(); var state = Resolve <IGameState>(); var asset = e.AssetId.Type switch { AssetType.Party => (object)state.GetSheet(e.AssetId), // TODO: Load game state assets via AssetManager? AssetType.Npc => state.GetSheet(e.AssetId), AssetType.Monster => assets.LoadSheet(e.AssetId), AssetType.Item => assets.LoadItem(e.AssetId), _ => null }; switch (e.Type) { case ContextType.Leader: _leader = (ICharacterSheet)asset; break; case ContextType.Subject: _subject = (ICharacterSheet)asset; break; case ContextType.Inventory: _inventory = (ICharacterSheet)asset; break; case ContextType.Combatant: _combatant = (ICharacterSheet)asset; break; case ContextType.Victim: _victim = (ICharacterSheet)asset; break; case ContextType.Weapon: _weapon = (ItemData)asset; break; } }); }
public Conversation(PartyCharacterId partyMemberId, ICharacterSheet npc) { On <EndDialogueEvent>(_ => Close()); On <UnloadMapEvent>(_ => Close()); On <DataChangeEvent>(OnDataChange); _partyMemberId = partyMemberId; _npc = npc ?? throw new ArgumentNullException(nameof(npc)); }
public void ShouldEquateAttributes() { //assign _characterSheet = new CharacterSheet(new Fighter(), new WoodElf(), _attributeSet); //act ICharacterAttribute actualAttribute = _characterSheet.Attribute(CharacterAttributeName.Dexterity); //assert actualAttribute.Should().Be(new DexterityAttribute()); }
public void ShouldReturnCorrectStatsList() { //assign _characterSheet = new CharacterSheet(new Wizard(), new HillDwarf(), _attributeSet); TextObj expectedTextOf = new TextObj("This Works!"); //act ITextObj actualTextOf = _characterSheet.StatsList(); //assert actualTextOf.Should().Be(expectedTextOf); }
public ConversationParticipantLabel(ICharacterSheet sheet, bool isRight) : base(isRight ? DialogPositioning.TopRight : DialogPositioning.TopLeft) { if (sheet == null) { throw new ArgumentNullException(nameof(sheet)); } var portraitId = sheet.PortraitId ?? SmallPortraitId.GibtEsNicht; var name = GetName(sheet, false); var fixedPos = new FixedPositionStack(); fixedPos.Add( new RepeatedBackground( new ButtonFrame( new UiSpriteElement <SmallPortraitId>(portraitId))), isRight ? 315 : 9, 4); fixedPos.Add( new RepeatedBackground( new ButtonFrame( new UiText(name))), isRight ? 236 : 45, 4, 79, 12); AttachChild(fixedPos); /* * Portrait background * Portrait background drop shadow * Portrait * Text * * Frame: * (9,4) (45,4) (124,4) * /-------x---------------------\ | Name (79x12) | | /---------------------/ (124,16) | | |(36x39)| | | \-------/ (45, 43) | | (236, 4) (315, 4) | /---------------------x-------\ |Name (79x12) | \-------------------- \ | |(36x39)| | | | | \-------/ (351, 43) | */ }
public void ShouldReturnStartingHitPointsForWoodElfFighter() { //arrange IHitPoints expectedHitPoints = new HitPoints(10); _characterSheet = new CharacterSheet(new Fighter(), new WoodElf(), _attributeSet); //act IHitPoints actualHitPoints = _characterSheet.HitPoints(); //assert actualHitPoints.Should().Be(expectedHitPoints); }
IText GetName(ICharacterSheet sheet, bool isRight) => new DynamicText(() => { var settings = Resolve <IGameplaySettings>(); var name = sheet.GetName(settings.Language); return(new[] { new TextBlock(name) { Alignment = isRight ? TextAlignment.Right : TextAlignment.Left, Color = FontColor.White, ArrangementFlags = TextArrangementFlags.NoWrap, } }); });
public void ShouldReturnActivatedAndNonActiveSkillsForHumanWizard() { //arrange _characterSheet = new CharacterSheet(new Wizard(), new Human(), new FakeWizardAttributeSet()); ICharacterAttribute attribute = _characterSheet.Attribute(CharacterAttributeName.Dexterity); SleightOfHand slightOfHand = new SleightOfHand((DexterityAttribute)attribute, true); //act _characterSheet.ActivateSkill(slightOfHand); //assert List <ISkill> actualSkills = _characterSheet.Skills(); actualSkills.First(item => item.Name().Equals(new TextObj("Sleight Of Hand"))).SkillBonus().Should().Be(new AttributeScore(1)); actualSkills.First(item => item.Name().Equals(new TextObj("Acrobatics"))).SkillBonus().Should().Be(new AttributeScore(-1)); }
public void ShouldApplyRacialBonusToAttributes() { //arrange AttributeScore expectedDexterityScore = new AttributeScore(12); AttributeScore expectedWisdomScore = new AttributeScore(11); _characterSheet = new CharacterSheet(new Fighter(), new WoodElf(), _attributeSet); //assert _characterSheet.Attribute(CharacterAttributeName.Strength).Score().Should().Be(new FakeAttribute().Score()); _characterSheet.Attribute(CharacterAttributeName.Dexterity).Score().Should().Be(expectedDexterityScore); _characterSheet.Attribute(CharacterAttributeName.Constitution).Score().Should().Be(new FakeAttribute().Score()); _characterSheet.Attribute(CharacterAttributeName.Intelligence).Score().Should().Be(new FakeAttribute().Score()); _characterSheet.Attribute(CharacterAttributeName.Wisdom).Score().Should().Be(expectedWisdomScore); _characterSheet.Attribute(CharacterAttributeName.Charisma).Score().Should().Be(new FakeAttribute().Score()); }
//public Item Create(IGameSectorBoundaries sectorBoundaries) //{ //} private Item GenerateSurvivor( ICharacterSheet characterSheet, Vector2 generatedPosition) { var yFrame = Randomness.Instance.From(0, 3); var xFrame = Randomness.Instance.From(0, yFrame == 3 ? 3 : 4); return(new Item() { DisplayName = $"Survivor #{Guid.NewGuid().ToString().Replace("-","")}", // needs a ItemNameGenerator, based on stats Used = false, InstantUse = Randomness.Instance.TrueOrFalse(), Stats = characterSheet as CharacterSheet, //TODO: OUCH !!! Design fail. Serialize to class, but use interfaces everywhere Tags = new List <string>() { "Items", "Generated", "Survivor" }, CurrentImage = new ImageData() { Id = $"itm_{Guid.NewGuid().ToString()}", Alpha = new AlphaBehaviour() { Alpha = 1.0f }, Path = "Image/faces", SelectedFrame = $"{IdPrefix}_{xFrame}_{yFrame}", Height = 32, Width = 32, Scale = new Vector2(1), Color = new Color ( 255, 128, 255 ), Position = new MovementBehaviour() { X = generatedPosition.X, Y = generatedPosition.Y }, Rotation = new RotationBehaviour() { Rotation = 0 }, //Randomness.Instance.From(0, 360) }, } }); }
//private void Start() //{ // StartCoroutine("FindTargetsWithDelay", 0.1f); //} //IEnumerator FindTargetsWithDelay(float delay) //{ // while (true) // { // yield return new WaitForSeconds(delay); // FindVisableTargets(); // } //} public List <Transform> FindVisableTargets() { visableTargets.Clear(); targetsInViewRadius = Physics2D.OverlapCircleAll(transform.position, viewRadius, targetMask); for (int i = 0; i < targetsInViewRadius.Length; i++) { Transform target = targetsInViewRadius[i].transform; if (target == this.transform) { continue; } Vector3 dirToTarget = (target.position - transform.position).normalized; if (Vector3.Angle(transform.forward, dirToTarget) < viewAngle / 2) { float disToTarget = Vector3.Distance(transform.position, target.position); Vector2 rayStart = new Vector2(transform.position.x + dirToTarget.x, transform.position.y + dirToTarget.y); RaycastHit2D hitInfo = Physics2D.Raycast(rayStart, dirToTarget, disToTarget); if (hitInfo == true) { Debug.DrawLine(transform.position, hitInfo.point, Color.red, 0.1f); ICharacterSheet characterSheet = hitInfo.transform.GetComponent <ICharacterSheet>(); if (characterSheet != null && characterSheet.GetTeam() != this.GetComponent <ICharacterSheet>().GetTeam()) { visableTargets.Add(target); } } } } return(visableTargets); }