Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idan domain ucc03 0 #24

Merged
merged 50 commits into from
May 23, 2017
Merged

Idan domain ucc03 0 #24

merged 50 commits into from
May 23, 2017

Conversation

idanizi
Copy link
Member

@idanizi idanizi commented May 21, 2017

UCC03 - Rooms Management - Domain Layer

  • UC022: Create Player
  • UC003: Create a New Room
  • UC004: Find an Existing Room
  • UC021: Enter a Room
  • UC020: Join Next Hand
  • UC013: Stand Up To Spectate

idanizi added 30 commits May 13, 2017 21:37
- bank and wallet extend same abstruct class.
  - todo: adapt bank to this change.
- implementing features to game center, room, player. related to 'join next hand'
idanizi added 17 commits May 20, 2017 20:12
# Conflicts:
#	Poker.BE/Poker.BE.Domain.Tests/Game/PlayerTests.cs
#	Poker.BE/Poker.BE.Domain.Tests/Game/RoomTests.cs
#	Poker.BE/Poker.BE.Domain/Game/Player.cs
#	Poker.BE/Poker.BE.Domain/Game/Room.cs
#	Poker.BE/Poker.BE.Domain/Game/Round.cs
#	Poker.BE/Poker.BE.Domain/Game/Turn.cs
#	Poker.BE/Poker.BE.Domain/Game/Wallet.cs
#	Poker.BE/Poker.BE.Domain/Poker.BE.Domain.csproj
#	Poker.BE/Poker.BE.Domain/Utility/Exceptions/NotEnoughMoneyException.cs
#	Poker.BE/Poker.BE.Domain/Utility/Exceptions/NotEnoughPlayersException.cs
@idanizi idanizi mentioned this pull request May 22, 2017
Copy link
Contributor

@tomer314 tomer314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically everything is fine, just see my comments/questions.
those are small changes.

this.CurrentHand = null;
this.Name = new GameConfig().Name;
}

public Player CreatePlayer()
{
var result = new Player();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the player suppose to have a name as I understood.
so maybe the CreatePlayer() method should get his name from the user's name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm.. yeah i thought about it. It because of the equals override i did. I can add a condition to the method that if the name is empty, do a shallow compare instead of deep. It should solve the problem. I'll add a test for that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

{
// TODO
throw new NotImplementedException();
creator = new Player();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

player should get the name from the user's name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Player has a nickname. User has a name. They can be edited separately

#region Constants
public static readonly int NCHAIRS_IN_ROOM = 10;
#endregion


#region Fields
private int index;
private bool isBusy;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change it to "isTaken"...
it's driving me crazy ;P

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure np

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

private double _minimumBet;
private string _name;
private GamePreferences _preferences;
#endregion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing the "chip policy" option that tells you how many chips do the player gets when joining the game.
this is NOT related to buy-in policy... it's a different thing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it to 'game preferences' as according to our design

@@ -7,32 +7,199 @@ namespace Poker.BE.Domain.Game
public class GameConfig
{

#region Fields
private int _maxNumberOfActivePlayers;
private int _maxNumberOfPlayers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we care only about the min/max number of players at the table, aka "active players"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Min/max numbers are for room configuration. Active Players is a property in Room class. Updated according to room state

/// </summary>
public int MinNumberOfPlayers { get; set; }
public int MaxNumberOfPlayers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this MaxNumberOfPlayers property

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. We need it

#region Properties
public State CurrentState { get; set; }
public Wallet Wallet { get { return _wallet; } }
public double WalletValue { get { return _wallet.Value; } private set { _wallet.Value = value; } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to choose:
we have the amountOfMoney field in the Wallet class and we have the value field in its father class.
we don't need both

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Issue #25 wallet

get { return config.BuyInCost; }
set { config.BuyInCost = value; }
}
#endregion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need all those properties? doesn't it enough to have the GamePrefences object related to it that holds all of this information?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By UC of create room.. yup, we do need them


#endregion
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't need this class at all...
let's use just one kind of currency.
the chip-to-money conversion will be calculated by the game preferences in the specific room (just divide the chip policy by the buy-in policy)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I differ. :) Let's talk on this f2f

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This related to #25

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job here idan! Can you explain me too what do we need this class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arieltobiana see Issue #25 wallet

@@ -6,16 +6,21 @@

namespace Poker.BE.Domain.Game
{
public class Wallet
public class Wallet : Utility.MoneyStorage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to decide if we need the MoneyStorage class.
see comment in that class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#25 wallet

#region Constructors
public RoomController()
{
service = new Service.Services.RoomsService();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Service.Services? seems like bad smell or maybe I miss something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you miss something.

[TestInitialize]
public void Before()
{
gameCenter = GameCenter.Instance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamecenter is singleton? nice good idea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. as we design. credit for all.

var expRoom2 = gameCenter.CreateNewRoom(level, config, out creator2).Name = "test room 2";

//Act
var actual = gameCenter.FindRoomsByCriteria(25);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is criteria 25?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integer bind to level parameter - look at the method definition

Assert.AreEqual(0, expRoom.ActivePlayers.Count);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good tests! 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

//{

//}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can we delete comments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arieltobiana - this tests are for Connect() Disconnect() methods of User class. that you didn't make any test for them and no documentation that explain what are their purpose. look at the //TODO: ...

RaisePreconditions(this.CurrentPlayer.Wallet.amountOfMoney + LiveBets[CurrentPlayer] - TotalRaise);
Raise(this.CurrentPlayer.Wallet.amountOfMoney + LiveBets[CurrentPlayer] - TotalRaise);
RaisePreconditions(this.CurrentPlayer.Wallet.AmountOfMoney + LiveBets[CurrentPlayer] - TotalRaise);
Raise(this.CurrentPlayer.Wallet.AmountOfMoney + LiveBets[CurrentPlayer] - TotalRaise);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mabrouk about the code convention 👍

newPartialPot.PlayersClaimPot.Add(player);
}

lastPartialPot.PlayersClaimPot.Remove(CurrentPlayer);

newPartialPot.AmountToClaim = amountToAdd + lastPlayerCurrentBet;
lastPartialPot.AmountToClaim -= newPartialPot.AmountToClaim;
newPartialPot.Value = lastPartialPot.Value - (lastPartialPot.AmountToClaim * lastPartialPot.PlayersClaimPot.Count);
lastPartialPot.Value = lastPartialPot.AmountToClaim * lastPartialPot.PlayersClaimPot.Count;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I understand the link between pot and partialpot. Do we have some pot tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomer314 - the pot expert 😆

image

return obj.GetHashCode();
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@idanizi what is the purpose of this class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added ///<summery>


#endregion
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job here idan! Can you explain me too what do we need this class?

}
#endregion

}// class
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job! I'm impressed!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

@idanizi idanizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered & Done

i've pass through @tomer314 and @arieltobiana reviews - many thanks!

return obj.GetHashCode();
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added ///<summery>


#endregion
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arieltobiana see Issue #25 wallet

}
#endregion

}// class
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

#region Constructors
public RoomController()
{
service = new Service.Services.RoomsService();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you miss something.

[TestInitialize]
public void Before()
{
gameCenter = GameCenter.Instance;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. as we design. credit for all.

{
throw new PlayerModeException("Unable to stand up: Player already a spectator.");
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗️ ❗️ ❗️ this is "leave room" not "stand up". make it as a SPIKE at trello. we dont have this UC!

image

deck = new Deck();
chairs = new Chair[Chair.NCHAIRS_IN_ROOM];
chairs = new Chair[NCHAIRS_IN_ROOM];

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

@@ -98,9 +173,50 @@ public Room(Player creator, GamePreferences preferences) : this(creator)
Preferences = preferences;
}

public Room(Player creator, GameConfig config) : this(creator, config.Preferences)
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for the creation, to add it to "passive players". he doesn't have spacial privileges

this.CurrentHand = null;
this.Name = new GameConfig().Name;
}

public Player CreatePlayer()
{
var result = new Player();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

newPartialPot.PlayersClaimPot.Add(player);
}

lastPartialPot.PlayersClaimPot.Remove(CurrentPlayer);

newPartialPot.AmountToClaim = amountToAdd + lastPlayerCurrentBet;
lastPartialPot.AmountToClaim -= newPartialPot.AmountToClaim;
newPartialPot.Value = lastPartialPot.Value - (lastPartialPot.AmountToClaim * lastPartialPot.PlayersClaimPot.Count);
lastPartialPot.Value = lastPartialPot.AmountToClaim * lastPartialPot.PlayersClaimPot.Count;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomer314 - the pot expert 😆

image

@idanizi idanizi merged commit 86a229c into master May 23, 2017
@idanizi idanizi mentioned this pull request May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants