Changeset 37703 for lang

Show
Ignore:
Timestamp:
05/26/10 01:29:21 (5 years ago)
Author:
isaisstillalive
Message:
  • CardInfoのシングルトンインスタンスをCardInfoアセンブリとCoreアセンブリで別々に作るという意味のわからないことをしてしまっていたため、一元化
Location:
lang/csharp/DominionEngine
Files:
1 added
12 modified

Legend:

Unmodified
Added
Removed
  • lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/Base/FeastTest.cs

    r37680 r37703  
    4949 
    5050            Assert.That(movingArgs[1].From.Position, Is.EqualTo(CardPosition.Supply)); 
    51             Assert.That(movingArgs[1].From.CardInfo, Is.EqualTo(Card<Copper>.cardInfo)); 
     51            Assert.That(movingArgs[1].From.CardInfo, Is.EqualTo(CardInfo<Copper>.Instance)); 
    5252            Assert.That(movingArgs[1].ToPosition, Is.EqualTo(CardPosition.Discard(0))); 
    5353        } 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/Base/MoneylenderTest.cs

    r37561 r37703  
    4242            Assert.That(choosingArgs.MinQuantity, Is.EqualTo(1)); 
    4343            Assert.That(choosingArgs.MaxQuantity, Is.EqualTo(1)); 
    44             Assert.That(choosingArgs.Filter(Card<Copper>.cardInfo), Is.True); 
    45             Assert.That(choosingArgs.Filter(Card<Silver>.cardInfo), Is.False); 
     44            Assert.That(choosingArgs.Filter(CardInfo<Copper>.Instance), Is.True); 
     45            Assert.That(choosingArgs.Filter(CardInfo<Silver>.Instance), Is.False); 
    4646 
    4747            Assert.That(coin, Is.EqualTo(3)); 
     
    7373            Assert.That(choosingArgs.MinQuantity, Is.EqualTo(1)); 
    7474            Assert.That(choosingArgs.MaxQuantity, Is.EqualTo(1)); 
    75             Assert.That(choosingArgs.Filter(Card<Copper>.cardInfo), Is.True); 
    76             Assert.That(choosingArgs.Filter(Card<Silver>.cardInfo), Is.False); 
     75            Assert.That(choosingArgs.Filter(CardInfo<Copper>.Instance), Is.True); 
     76            Assert.That(choosingArgs.Filter(CardInfo<Silver>.Instance), Is.False); 
    7777 
    7878            Assert.That(coin, Is.EqualTo(0)); 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/Base/WitchTest.cs

    r37680 r37703  
    3434 
    3535            Assert.That(movingArgs.Count, Is.EqualTo(3)); 
    36             Assert.That(movingArgs[0].From.CardInfo, Is.EqualTo(Card<Curse>.cardInfo)); 
     36            Assert.That(movingArgs[0].From.CardInfo, Is.EqualTo(CardInfo<Curse>.Instance)); 
    3737            Assert.That(movingArgs[0].From.Position, Is.EqualTo(CardPosition.Supply)); 
    3838            Assert.That(movingArgs[0].ToPosition, Is.EqualTo(CardPosition.Discard(2))); 
    3939 
    40             Assert.That(movingArgs[1].From.CardInfo, Is.EqualTo(Card<Curse>.cardInfo)); 
     40            Assert.That(movingArgs[1].From.CardInfo, Is.EqualTo(CardInfo<Curse>.Instance)); 
    4141            Assert.That(movingArgs[1].From.Position, Is.EqualTo(CardPosition.Supply)); 
    4242            Assert.That(movingArgs[1].ToPosition, Is.EqualTo(CardPosition.Discard(3))); 
    4343 
    44             Assert.That(movingArgs[2].From.CardInfo, Is.EqualTo(Card<Curse>.cardInfo)); 
     44            Assert.That(movingArgs[2].From.CardInfo, Is.EqualTo(CardInfo<Curse>.Instance)); 
    4545            Assert.That(movingArgs[2].From.Position, Is.EqualTo(CardPosition.Supply)); 
    4646            Assert.That(movingArgs[2].ToPosition, Is.EqualTo(CardPosition.Discard(0))); 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/DDL/AnyPlayerTest.cs

    r37692 r37703  
    215215            Func<ICardInfo, bool> filter = anyPlayer.ChooseTypeFilter<ITreasure>(cardinfo => true); 
    216216 
    217             Assert.That(filter(Card<Copper>.cardInfo), Is.True); 
    218             Assert.That(filter(Card<Silver>.cardInfo), Is.True); 
    219             Assert.That(filter(Card<Estate>.cardInfo), Is.False); 
     217            Assert.That(filter(CardInfo<Copper>.Instance), Is.True); 
     218            Assert.That(filter(CardInfo<Silver>.Instance), Is.True); 
     219            Assert.That(filter(CardInfo<Estate>.Instance), Is.False); 
    220220        } 
    221221 
     
    238238 
    239239            Assert.That(choosingArgs.Filter, Is.Not.SameAs(filter)); 
    240             Assert.That(choosingArgs.Filter(Card<Copper>.cardInfo), Is.True); 
    241             Assert.That(choosingArgs.Filter(Card<Silver>.cardInfo), Is.True); 
    242             Assert.That(choosingArgs.Filter(Card<Estate>.cardInfo), Is.False); 
     240            Assert.That(choosingArgs.Filter(CardInfo<Copper>.Instance), Is.True); 
     241            Assert.That(choosingArgs.Filter(CardInfo<Silver>.Instance), Is.True); 
     242            Assert.That(choosingArgs.Filter(CardInfo<Estate>.Instance), Is.False); 
    243243        } 
    244244 
     
    493493            anyPlayer.Gain<Curse>(); 
    494494 
    495             Assert.That(movingArgs.From.CardInfo, Is.EqualTo(Card<Curse>.cardInfo)); 
     495            Assert.That(movingArgs.From.CardInfo, Is.EqualTo(CardInfo<Curse>.Instance)); 
    496496            Assert.That(movingArgs.From.Position, Is.EqualTo(CardPosition.Supply)); 
    497497            Assert.That(movingArgs.ToPosition, Is.EqualTo(CardPosition.Discard(player))); 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo.Test/DominionEngine.CardInfo.Test.csproj

    r37575 r37703  
    5858    <Compile Include="BasicCardTest.cs" /> 
    5959    <Compile Include="CardInfoResourcesTest.cs" /> 
     60    <Compile Include="CardInfoGenericTest.cs" /> 
    6061    <Compile Include="DDL\CardTest.cs" /> 
    6162    <Compile Include="DDL\TurnPlayerTest.cs" /> 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo/CardInfo/CardInfo.cs

    r37654 r37703  
    9797        #endregion 
    9898    } 
     99 
     100    public static class CardInfo<T> 
     101        where T : ICardInfo, new() 
     102    { 
     103        public static ICardInfo Instance { get; internal set; } 
     104 
     105        static CardInfo() 
     106        { 
     107            Instance = new T(); 
     108        } 
     109    } 
    99110} 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo/DDL/AnyPlayer.cs

    r37680 r37703  
    593593            where T : ICardInfo, new() 
    594594        { 
    595             Gain(Card<T>.cardInfo); 
     595            Gain(CardInfo<T>.Instance); 
    596596        } 
    597597 
  • lang/csharp/DominionEngine/DominionEngine.CardInfo/DDL/Card.cs

    r37680 r37703  
    121121        where T : ICardInfo, new() 
    122122    { 
    123         internal static ICardInfo cardInfo = new T(); 
    124  
    125123        /// <summary> 
    126124        /// コンストラクタ 
    127125        /// </summary> 
    128126        /// <param name="position">位置</param> 
    129         public Card(CardPosition position) : base(cardInfo, position) { } 
     127        public Card(CardPosition position) : base(CardInfo<T>.Instance, position) { } 
    130128    } 
    131129} 
  • lang/csharp/DominionEngine/DominionEngine.Core.Test/CardList/UnitaryCardListTest.cs

    r37569 r37703  
    1515        { 
    1616            UnitaryCardList cardlist = new UnitaryCardList<Estate>(players); 
    17             Assert.That(cardlist.Count, Is.EqualTo(Card<Estate>.cardInfo.GetQuantity(players))); 
    18             Assert.That(cardlist, Is.All.Property("CardInfo").SameAs(Card<Estate>.cardInfo)); 
     17            Assert.That(cardlist.Count, Is.EqualTo(CardInfo<Estate>.Instance.GetQuantity(players))); 
     18            Assert.That(cardlist, Is.All.Property("CardInfo").SameAs(CardInfo<Estate>.Instance)); 
    1919        } 
    2020    } 
  • lang/csharp/DominionEngine/DominionEngine.Core/Card/Card.cs

    r37630 r37703  
    2121        where T : ICardInfo, new() 
    2222    { 
    23         internal static ICardInfo cardInfo = new T(); 
    24         public override ICardInfo CardInfo { get { return cardInfo; } } 
     23        public override ICardInfo CardInfo { get { return CardInfo<T>.Instance; } } 
    2524    } 
    2625} 
  • lang/csharp/DominionEngine/DominionEngine.Core/CardList/UnitaryCardList.cs

    r37569 r37703  
    3131        where T : ICardInfo, new() 
    3232    { 
    33         internal ICardInfo cardInfo = Card<T>.cardInfo; 
    34         public override ICardInfo CardInfo { get { return cardInfo; } } 
     33        public override ICardInfo CardInfo { get { return CardInfo<T>.Instance; } } 
    3534 
    3635        public UnitaryCardList(int players) 
    3736            : base() 
    3837        { 
    39             int quantity = Card<T>.cardInfo.GetQuantity(players); 
     38            int quantity = CardInfo.GetQuantity(players); 
    4039            for (int i = 0; i < quantity; i++) 
    4140                Items.Add(new Card<T>()); 
  • lang/csharp/DominionEngine/DominionEngine.Core/Game.cs

    r37669 r37703  
    466466            CardInfo.AnyPlayer.Choosing += AnyPlayer_Choosing; 
    467467            CardInfo.Card.Moving += Card_Moving; 
    468              
     468 
    469469 
    470470            CardInfo.TurnPlayer.ClearEvent(); 
     
    531531            where T : ICardInfo, new() 
    532532        { 
    533             return Buy(Card<T>.cardInfo); 
     533            return Buy(CardInfo<T>.Instance); 
    534534        } 
    535535