public static Action NextAction(List<int> pinFalls) { ActionMaster am = new ActionMaster(); Action currentAction = new Action(); foreach (int pinFall in pinFalls) { currentAction = am.Bowl(pinFall); } return currentAction; }
public static ActionState NextAction(List<int> pinFalls) { ActionMaster actionMaster = new ActionMaster(); ActionState currentAction = new ActionState(); foreach (int pinFall in pinFalls) { currentAction = actionMaster.Bowl (pinFall); } return currentAction; }
public void PerformAction(ActionMaster.Action action) { if (action == ActionMaster.Action.Tidy) { animator.SetTrigger("tidyTrigger"); } else if (action == ActionMaster.Action.Reset || action == ActionMaster.Action.EndTurn) { animator.SetTrigger("resetTrigger"); pinCounter.Reset(); } else if (action == ActionMaster.Action.EndGame) { throw new UnityException("Endgame not implemented yet"); } }
public void PerformAction(ActionMaster.Action result) { if (result == ActionMaster.Action.Tidy) { animator.SetTrigger("tidyTrigger"); } else if (result == ActionMaster.Action.EndTurn || result == ActionMaster.Action.Reset) { animator.SetTrigger("resetTrigger"); } // TODO: Need to write the code to handle this! else if (result == ActionMaster.Action.EndGame) { throw new UnityException("Not sure how to handle this yet!"); } }
void PerformAction (ActionMaster.Action action) { // Debug.Log( action ); switch ( action ) { case ActionMaster.Action.Tidy: pinSetter.ActionTidy(); break; case ActionMaster.Action.Reset: case ActionMaster.Action.EndTurn: pinSetter.ActionReset(); break; case ActionMaster.Action.EndGame: EndGame(); break; } }
public void PerformAction(ActionMaster.Action mAction) { if(mAction == ActionMaster.Action.Tidy){ animator.SetTrigger("tidyTrigger"); } else if(mAction == ActionMaster.Action.Reset) { animator.SetTrigger("resetTrigger"); pinCounter.Reset(); } else if(mAction == ActionMaster.Action.EndTurn){ animator.SetTrigger("resetTrigger"); pinCounter.Reset(); } else if(mAction == ActionMaster.Action.EndGame) { throw new UnityException("sqoi END GAME"); } }
public void T04FinalFrameStrikeGrantsTwoExtraTurns(){ foreach (int i in Enumerable.Range(0, 20)) { if (i == 19){ Assert.AreEqual(reset, actionMaster.Bowl(10)); Assert.AreEqual(tidy, actionMaster.Bowl(3)); Assert.AreEqual(endGame, actionMaster.Bowl(3)); }else { actionMaster.Bowl(3); } } // foreach (int i in Enumerable.Range(0, 20)) { actionMaster = new ActionMaster(); foreach (int i in Enumerable.Range(0, 20)) { if (i == 19){ Assert.AreEqual(reset, actionMaster.Bowl(10)); Assert.AreEqual(reset, actionMaster.Bowl(10)); Assert.AreEqual(endGame, actionMaster.Bowl(10)); }else { actionMaster.Bowl(3); } } // foreach (int i in Enumerable.Range(0, 20)) { } // public void T04FinalFrameStrikeGrantsTwoExtraTurns(){
public void T04Bowl28SpareReturnsEndTurn() { pinFalls.Add(8); pinFalls.Add(2); Assert.AreEqual(endTurn, ActionMaster.NextAction(pinFalls)); }
public void T01OneStrikeReturnsEndTurn() { pinFalls.Add(10); Assert.AreEqual(endTurn, ActionMaster.NextAction(pinFalls)); }
public void T09GutterBallThenStrikeEndsTurn() { int[] rolls = { 0, 10, 5, 5 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T07GameEndsAtBowl20() { //bowl 18 balls to get to last frame int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
// Use this for initialization void Start() { PinsParent = GameObject.Find ("Pins"); anim = GetComponent<Animator> (); actionMaster = GameObject.FindObjectOfType<ActionMaster> (); ball = GameObject.FindObjectOfType<Ball> (); }
public void T04_BowlStrikeInLastFrameReturnsReset() { int [] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void T01_StrikeReturnsEndTurn() { int[] rolls = { 10 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T06_GameEndSpareLastFrame() { int [] rolls = { 8, 2, 7, 3, 3, 4, 10, 2, 8, 10, 10, 8, 0, 10, 8, 2, 9 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
private void LoadFromId(int actionMasterId) { if (CachedEntityCommander.IsTypeRegistered(typeof(ActionMasterInfo))) { ActionMasterInfo actionMasterInfo=Find(GetList(), actionMasterId); if(actionMasterInfo==null) throw new AppException("未能在缓存中找到相应的键值对象"); Copy(actionMasterInfo, this); } else { ActionMaster actionMaster=new ActionMaster( actionMasterId); if(actionMaster.IsNew) throw new AppException("尚未初始化"); LoadFromDAL(this, actionMaster); } }
//数据持久化 internal static void SaveToDb(ActionMasterInfo pActionMasterInfo, ActionMaster pActionMaster,bool pIsNew) { pActionMaster.ActionMasterId = pActionMasterInfo.actionMasterId; pActionMaster.ActionId = pActionMasterInfo.actionId; pActionMaster.MasterId = pActionMasterInfo.masterId; pActionMaster.IsPass = pActionMasterInfo.isPass; pActionMaster.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pActionMaster.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(ActionMasterInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pActionMasterInfo.actionMasterId = pActionMaster.ActionMasterId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(ActionMasterInfo))) { ResetCache(); } }
//从后台获取数据 internal static void LoadFromDAL(ActionMasterInfo pActionMasterInfo, ActionMaster pActionMaster) { pActionMasterInfo.actionMasterId = pActionMaster.ActionMasterId; pActionMasterInfo.actionId = pActionMaster.ActionId; pActionMasterInfo.masterId = pActionMaster.MasterId; pActionMasterInfo.isPass = pActionMaster.IsPass; pActionMasterInfo.Loaded=true; }
/// <summary> /// 保存 /// </summary> public override void Save() { if(!m_Loaded)//新增 { ActionMaster actionMaster=new ActionMaster(); SaveToDb(this, actionMaster,true); } else//修改 { ActionMaster actionMaster=new ActionMaster(actionMasterId); if(actionMaster.IsNew) throw new AppException("该数据已经不存在了"); SaveToDb(this, actionMaster,false); } }
public void T07YouTubeRollsEndInEndGame() { int[] rolls = { 8, 2, 7, 3, 3, 4, 10, 2, 8, 10, 10, 8, 0, 10, 8, 2, 9 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void T09_LastFrameBowl10_0ReturnsTidy() { int [] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 0 }; Assert.AreEqual(tidy, ActionMaster.NextAction(rolls.ToList())); }
public void T01BowlNotTenReturnsTidy(){ foreach (int i in Enumerable.Range(0, 9)){ actionMaster = new ActionMaster(); Assert.AreEqual(tidy, actionMaster.Bowl(i)); } }
public void T11_LastThreeFramesStrikeReturnsEndGame() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void T02_Bowl8ReturnsTidy() { int[] rolls = { 8 }; Assert.AreEqual(tidy, ActionMaster.NextAction(rolls.ToList())); }
public void T03BowlSpareReturnsEndTurn() { int[] rolls = { 8, 2 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T05_BowlSpareInLasetFrameReturnsReset() { int [] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
private void AreEqual(int[] bowls, ActionMaster.Action action) { Assert.AreEqual(action, ActionMaster.NextAction(bowls.ToList())); }
public void T08_LastFrameBowl10_1ReturnsReset() { int [] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }; Assert.AreEqual(tidy, ActionMaster.NextAction(rolls.ToList())); }
public void T13Bowl6Then4ThenStrikeReturnsEndTurn() { int[] rolls = { 6, 4, 10 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T10_Bowl0_10_5_1ReturnEndTurn() { int[] rolls = { 0, 10, 5, 1 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T05Bowl1Then9SpareInBowls19And20ReturnsReset() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void T11ResetOnLastFrameTwoStrikes() { //bowl 18 balls to get to last frame int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void T06Bowl1And1InBowls19And20ReturnsEndGame() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void T05CheckResetAtLastFrameSpare() { //bowl 18 balls to get to last frame int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void T07StrikeAtBowl19PlusStrikeAtBowl20ReturnsReset() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void T08TidyIfStrikeThenNotOnLastFrame() { //bowl 18 balls to get to last frame int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }; Assert.AreEqual(tidy, ActionMaster.NextAction(rolls.ToList())); }
public void T08Bowl21ReturnsEndGame() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void T10LastFrameTurkey() { //bowl 18 balls to get to last frame int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void T10StrikeAtBowl19Plus5AtBowl20ReturnsTidy() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 5 }; Assert.AreEqual(tidy, ActionMaster.NextAction(rolls.ToList())); }
public void T02Bowl8ReturnsTidy() { pinFalls.Add(8); Assert.AreEqual(tidy, ActionMaster.NextAction(pinFalls)); }
public void T11BowlCountAtEndOfSecondFrameWhitStrikeAtEndOfFirstFrame() { int[] rolls = { 0, 10, 5, 1 }; Assert.AreEqual(endTurn, ActionMaster.NextAction(rolls.ToList())); }
public void T06CheckResetAtSpareInLastFrame() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9 }; Assert.AreEqual(reset, ActionMaster.NextAction(rolls.ToList())); }
public void SetUp() { actionMaster = new ActionMaster(); }
public void T08GameEndsAtBowl20() { int[] rolls = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Assert.AreEqual(endGame, ActionMaster.NextAction(rolls.ToList())); }
public void Setup(){ actionMaster = new ActionMaster(); }