Skip to content

Commit

Permalink
Refactored namespaces for standardization reasons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Latency committed Feb 4, 2018
1 parent 9036d7d commit 70d3800
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 77 deletions.
39 changes: 19 additions & 20 deletions HearthStone.Database/Card.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#region

using System.Linq;
using HearthDb.CardDefs;
using HearthDb.Enums;
using static HearthDb.Enums.GameTag;
using HearthStone.Database.CardDefs;
using HearthStone.Database.Enums;

#endregion

namespace HearthDb
namespace HearthStone.Database
{
public class Card
{
Expand All @@ -28,27 +27,27 @@ internal Card(Entity entity)

public string FlavorText => GetLocFlavorText(DefaultLanguage);

public CardClass Class => (CardClass)Entity.GetTag(CLASS);
public CardClass Class => (CardClass)Entity.GetTag(GameTag.CLASS);

public Rarity Rarity => (Rarity)Entity.GetTag(RARITY);
public Rarity Rarity => (Rarity)Entity.GetTag(GameTag.RARITY);

public CardType Type => (CardType)Entity.GetTag(CARDTYPE);
public CardType Type => (CardType)Entity.GetTag(GameTag.CARDTYPE);

public Race Race => (Race)Entity.GetTag(CARDRACE);
public Race Race => (Race)Entity.GetTag(GameTag.CARDRACE);

public CardSet Set => (CardSet)Entity.GetTag(CARD_SET);
public CardSet Set => (CardSet)Entity.GetTag(GameTag.CARD_SET);

public Faction Faction => (Faction)Entity.GetTag(FACTION);
public Faction Faction => (Faction)Entity.GetTag(GameTag.FACTION);

public int Cost => Entity.GetTag(COST);
public int Cost => Entity.GetTag(GameTag.COST);

public int Attack => Entity.GetTag(ATK);
public int Attack => Entity.GetTag(GameTag.ATK);

public int Health => Entity.GetTag(HEALTH);
public int Health => Entity.GetTag(GameTag.HEALTH);

public int Durability => Entity.GetTag(DURABILITY);
public int Durability => Entity.GetTag(GameTag.DURABILITY);

public int Armor => Entity.GetTag(ARMOR);
public int Armor => Entity.GetTag(GameTag.ARMOR);

public string[] Mechanics
{
Expand All @@ -62,25 +61,25 @@ public string[] Mechanics
}
}

public string ArtistName => Entity.GetInnerValue(ARTISTNAME);
public string ArtistName => Entity.GetInnerValue(GameTag.ARTISTNAME);

public string[] EntourageCardIds => Entity.EntourageCards.Select(x => x.CardId).ToArray();

public Locale DefaultLanguage { get; set; } = Locale.enUS;

public bool Collectible => Entity.GetTag(COLLECTIBLE) != 0;
public bool Collectible => Entity.GetTag(GameTag.COLLECTIBLE) != 0;

public string GetLocName(Locale lang) => Entity.GetLocString(CARDNAME, lang);
public string GetLocName(Locale lang) => Entity.GetLocString(GameTag.CARDNAME, lang);

public string GetLocText(Locale lang)
{
var text = Entity.GetLocString(CARDTEXT_INHAND, lang)?.Replace("_", "\u00A0").Trim();
var text = Entity.GetLocString(GameTag.CARDTEXT_INHAND, lang)?.Replace("_", "\u00A0").Trim();
if(text == null)
return null;
var index = text.IndexOf('@');
return index > 0 ? text.Substring(index + 1) : text;
}

public string GetLocFlavorText(Locale lang) => Entity.GetLocString(FLAVORTEXT, lang);
public string GetLocFlavorText(Locale lang) => Entity.GetLocString(GameTag.FLAVORTEXT, lang);
}
}
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/CardDefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
[XmlRoot("CardDefs")]
public class CardDefs
Expand Down
33 changes: 16 additions & 17 deletions HearthStone.Database/CardDefs/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using HearthDb.Enums;
using static HearthDb.Enums.Locale;
using HearthStone.Database.Enums;

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class Entity
{
Expand Down Expand Up @@ -54,33 +53,33 @@ public string GetLocString(GameTag gameTag, Locale lang)
return null;
switch(lang)
{
case deDE:
case Locale.deDE:
return tag.LocStringDeDe;
case enUS:
case Locale.enUS:
return tag.LocStringEnUs;
case esES:
case Locale.esES:
return tag.LocStringEsEs;
case esMX:
case Locale.esMX:
return tag.LocStringEsMx;
case frFR:
case Locale.frFR:
return tag.LocStringFrFr;
case itIT:
case Locale.itIT:
return tag.LocStringItIt;
case jaJP:
case Locale.jaJP:
return tag.LocStringJaJp;
case koKR:
case Locale.koKR:
return tag.LocStringKoKr;
case plPL:
case Locale.plPL:
return tag.LocStringPlPl;
case ptBR:
case Locale.ptBR:
return tag.LocStringPtBr;
case ruRU:
case Locale.ruRU:
return tag.LocStringRuRu;
case zhCN:
case Locale.zhCN:
return tag.LocStringZhCn;
case zhTW:
case Locale.zhTW:
return tag.LocStringZhTw;
case thTH:
case Locale.thTH:
return tag.LocStringThTh;
default:
return null;
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/EntourageCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class EntourageCard
{
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/PlayRequirement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class PlayRequirement
{
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/Power.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class Power
{
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class Tag
{
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/CardDefs/TriggeredPowerHistoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#endregion

namespace HearthDb.CardDefs
namespace HearthStone.Database.CardDefs
{
public class TriggeredPowerHistoryInfo
{
Expand Down
3 changes: 1 addition & 2 deletions HearthStone.Database/CardIds.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ReSharper disable InconsistentNaming
namespace HearthDb
namespace HearthStone.Database
{
/* THIS CLASS WAS GENERATED BY HearthDb.CardIdGenerator. DO NOT EDIT. */
public class CardIds
Expand Down
4 changes: 2 additions & 2 deletions HearthStone.Database/Cards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;
using HearthDb.Enums;
using HearthStone.Database.Enums;

#endregion

namespace HearthDb
namespace HearthStone.Database
{
public static class Cards
{
Expand Down
5 changes: 3 additions & 2 deletions HearthStone.Database/Deckstrings/Deck.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using HearthDb.Enums;
using HearthStone.Database.Enums;

namespace HearthDb.Deckstrings

namespace HearthStone.Database.Deckstrings
{
public class Deck
{
Expand Down
5 changes: 3 additions & 2 deletions HearthStone.Database/Deckstrings/DeckSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using System.IO;
using System.Linq;
using System.Text;
using HearthDb.Enums;
using HearthStone.Database.Enums;

namespace HearthDb.Deckstrings

namespace HearthStone.Database.Deckstrings
{
public class DeckSerializer
{
Expand Down
3 changes: 2 additions & 1 deletion HearthStone.Database/Deckstrings/InvalidDeckException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;

namespace HearthDb.Deckstrings

namespace HearthStone.Database.Deckstrings
{
public class InvalidDeckException : Exception
{
Expand Down
3 changes: 2 additions & 1 deletion HearthStone.Database/Deckstrings/VarInt.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;

namespace HearthDb.Deckstrings

namespace HearthStone.Database.Deckstrings
{
internal static class VarInt
{
Expand Down
36 changes: 18 additions & 18 deletions HearthStone.Database/Enums/Converters.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using static HearthDb.Enums.BnetGameType;

namespace HearthDb.Enums

namespace HearthStone.Database.Enums
{
public static class Converters
{
Expand All @@ -10,37 +10,37 @@ public static BnetGameType GetBnetGameType(GameType gameType, FormatType format)
switch(gameType)
{
case GameType.GT_UNKNOWN:
return BGT_UNKNOWN;
return BnetGameType.BGT_UNKNOWN;
case GameType.GT_VS_AI:
return BGT_VS_AI;
return BnetGameType.BGT_VS_AI;
case GameType.GT_VS_FRIEND:
return BGT_FRIENDS;
return BnetGameType.BGT_FRIENDS;
case GameType.GT_TUTORIAL:
return BGT_TUTORIAL;
return BnetGameType.BGT_TUTORIAL;
case GameType.GT_ARENA:
return BGT_ARENA;
return BnetGameType.BGT_ARENA;
case GameType.GT_TEST:
return BGT_TEST1;
return BnetGameType.BGT_TEST1;
case GameType.GT_RANKED:
return format == FormatType.FT_STANDARD ? BGT_RANKED_STANDARD : BGT_RANKED_WILD;
return format == FormatType.FT_STANDARD ? BnetGameType.BGT_RANKED_STANDARD : BnetGameType.BGT_RANKED_WILD;
case GameType.GT_CASUAL:
return format == FormatType.FT_STANDARD? BGT_CASUAL_STANDARD : BGT_CASUAL_WILD;
return format == FormatType.FT_STANDARD? BnetGameType.BGT_CASUAL_STANDARD : BnetGameType.BGT_CASUAL_WILD;
case GameType.GT_TAVERNBRAWL:
return BGT_TAVERNBRAWL_PVP;
return BnetGameType.BGT_TAVERNBRAWL_PVP;
case GameType.GT_TB_1P_VS_AI:
return BGT_TAVERNBRAWL_1P_VERSUS_AI;
return BnetGameType.BGT_TAVERNBRAWL_1P_VERSUS_AI;
case GameType.GT_TB_2P_COOP:
return BGT_TAVERNBRAWL_2P_COOP;
return BnetGameType.BGT_TAVERNBRAWL_2P_COOP;
case GameType.GT_FSG_BRAWL:
return BGT_FSG_BRAWL_VS_FRIEND;
return BnetGameType.BGT_FSG_BRAWL_VS_FRIEND;
case GameType.GT_FSG_BRAWL_1P_VS_AI:
return BGT_FSG_BRAWL_1P_VERSUS_AI;
return BnetGameType.BGT_FSG_BRAWL_1P_VERSUS_AI;
case GameType.GT_FSG_BRAWL_2P_COOP:
return BGT_FSG_BRAWL_2P_COOP;
return BnetGameType.BGT_FSG_BRAWL_2P_COOP;
case GameType.GT_FSG_BRAWL_VS_FRIEND:
return BGT_FSG_BRAWL_VS_FRIEND;
return BnetGameType.BGT_FSG_BRAWL_VS_FRIEND;
default:
return BGT_UNKNOWN;
return BnetGameType.BGT_UNKNOWN;
}
}

Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/Enums/Dictionaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#endregion

namespace HearthDb.Enums
namespace HearthStone.Database.Enums
{
public static class Dictionaries
{
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/Enums/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace HearthDb.Enums
namespace HearthStone.Database.Enums
{
/* THIS FILE WAS GENERATED BY HearthDb.EnumsGenerator. DO NOT EDIT. */

Expand Down
6 changes: 3 additions & 3 deletions HearthStone.Database/HearthStone.Database.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>10.0.1</Version>
<Version>1.0.1</Version>
<TargetFrameworks>net471;net45;netcoreapp2.0;netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>snKey.snk</AssemblyOriginatorKeyFile>
Expand All @@ -19,8 +19,8 @@
<PackageId>HearthStone.Database</PackageId>
<PackageTags>HearthStone Database</PackageTags>
<PackageReleaseNotes>Initial build &amp; release package.</PackageReleaseNotes>
<RootNamespace>HearthDb</RootNamespace>
<AssemblyName>HearthDb</AssemblyName>
<RootNamespace>HearthStone.Database</RootNamespace>
<AssemblyName>HearthStone.Database</AssemblyName>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down
2 changes: 1 addition & 1 deletion HearthStone.Database/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#endregion

namespace HearthDb
namespace HearthStone.Database
{
public static class Info
{
Expand Down

0 comments on commit 70d3800

Please sign in to comment.