private void BotMainLoop() { try { if (SettingsManager.settings.champ && !SettingsManager.settings.Initialize()) { checkChamp.Checked = false; checkChamp.Enabled = false; } BoxOpener.SetBoxes(); if (SettingsManager.settings.boxTime.CompareTo(DateTime.Now) > 0) { Logger.Log("Next box opens at: " + SettingsManager.settings.boxTime.ToString()); } while (toogleState == CheckState.Checked && toogleStartStop.Checked) { if (BoxOpener.Run() == Messages.Restart) { Game.RestartProtocol(); } if (Championship.Run() == Messages.Restart) { Game.RestartProtocol(); Championship.SetChamp(); } if (QuickFight.Run(loops: 5) == Messages.Restart) { Game.RestartProtocol(); } if (Hibernate.Run() == Messages.Hibernate) { toogleState = CheckState.Indeterminate; this.WindowState = FormWindowState.Minimized; } } toogleState = CheckState.Unchecked; toogleStartStop.Checked = false; sw.Stop(); TimeSpan ts = sw.Elapsed; SettingsManager.currentStatistics.working += ts.TotalHours; } catch (Exception e) { Logger.Log("BotMainLoop Exception: " + e.Message, debug: true); } }
public static void Main() { var nocturnal = new Nocturnal(); var hibernate = new Hibernate(); var animals = new List <Animal> { new Lion(nocturnal), new Cat(nocturnal), new Bear(hibernate) }; var Garfield = new Cat(hibernate); animals.Add(Garfield); animals.ForEach(a => a.Sleep()); }
public void HibernateTest() { Hibernate request = new Hibernate(); var result = JsonConvert.DeserializeObject <KodiJSON.System.Response.HibernateResponse>(ExecuteTest.GetResponse(request)); }
public FileModule() { hibernate = new Hibernate(); }
public ProjectModule() { hibernate = new Hibernate(); }
//Business-related numbers public CourseModule() { hibernate = new Hibernate(); }
public UserModule() { hibernate = new Hibernate(); }
public void CheckConnection() { Hibernate.CheckConnection(); }
/// <summary> /// Evaluates the frame. /// </summary> /// <param name="mSecond">The m second.</param> public void EvaluateFrame(ulong time) { //System.Console.WriteLine("Timeline: EvaluateFrame {" + time.ToString() + "}"); _isRebuildList = true; _isRebuildLink = true; ulong listFractionTime; ulong linkFractionTime; int listFractionTimeIndex = 0; int linkFractionTimeIndex = 0; bool isFirstLoop = true; while (true) { //+ check for escape if (time <= 0) { return; } //+ new timelice Timeslice timeslice = _timeslices[_timesliceIndex]; Dictionary <ulong, List <TElement> > list = timeslice.List; Dictionary <ulong, LinkHead> link = timeslice.Link; listFractionTime = FillWorkingFractionArray <List <TElement> >(list, ref _listWorkingFractionArray, TimePrecision.ListWorkingFractionSize, ref listFractionTimeIndex, ref _listMaxWorkingFraction); linkFractionTime = FillWorkingFractionArray <LinkHead>(link, ref _linkWorkingFractionArray, TimePrecision.LinkWorkingFractionSize, ref linkFractionTimeIndex, ref _linkMaxWorkingFraction); //+ process time-slices ulong fractionTime = System.Math.Min(listFractionTime, linkFractionTime); if (isFirstLoop == true) { isFirstLoop = false; time += fractionTime; } ulong lastFractionTime = 0; while (fractionTime < ulong.MaxValue) { //+ advance time-slice + check for escape time -= (fractionTime - lastFractionTime); if (time <= 0) { return; } //+ evaluate time #region Evalutate Time if (listFractionTime == fractionTime) { List <TElement> objectList = list[listFractionTime]; int objectIndex; int objectListCount = objectList.Count; for (objectIndex = 0; objectIndex <= (objectListCount - 5); objectIndex += 5) { _threadPool.Add(objectList.GetRange(objectIndex, 5)); } if (objectIndex != objectListCount) { _threadPool.Add(objectList.GetRange(objectIndex, objectListCount - objectIndex)); } //+ next list.Remove(listFractionTime); listFractionTime = (listFractionTimeIndex > 0 ? _listWorkingFractionArray[--listFractionTimeIndex] : ulong.MaxValue); } if (linkFractionTime == fractionTime) { LinkBase nextItem; LinkHead head = link[linkFractionTime]; LinkBase item = head.Chain; int itemCount = head.Count; int itemIndex; for (itemIndex = 0; itemIndex <= (itemCount - 5); itemIndex += 5) { LinkBase item0 = item; nextItem = item0.NextLink; item0.NextLink = null; //+ paranoia LinkBase item1 = nextItem; nextItem = item1.NextLink; item1.NextLink = null; //+ paranoia LinkBase item2 = nextItem; nextItem = item2.NextLink; item2.NextLink = null; //+ paranoia LinkBase item3 = nextItem; nextItem = item3.NextLink; item3.NextLink = null; //+ paranoia LinkBase item4 = nextItem; nextItem = item4.NextLink; item4.NextLink = null; //+ paranoia item = nextItem; _threadPool.Add(new LinkBase[] { item0, item1, item2, item3, item4 }); } if (itemIndex != itemCount) { itemCount -= itemIndex; LinkBase[] itemArray = new LinkBase[itemCount]; itemIndex = 0; //for (; itemIndex < itemCount; /*item != null;*/ item = nextItem) //for (; item != null; item = nextItem) for (; itemIndex < itemCount; item = nextItem) { nextItem = item.NextLink; item.NextLink = null; //+ paranoia itemArray[itemIndex++] = item; } _threadPool.Add(itemArray); } //+ next link.Remove(linkFractionTime); linkFractionTime = (linkFractionTimeIndex > 0 ? _linkWorkingFractionArray[--linkFractionTimeIndex] : ulong.MaxValue); } #endregion Evalutate Time _threadPool.Join(); //System.Console.WriteLine("Timeslice: " + time.ToString()); //+ process state-change #region Process State-Change ContextChange nextContext; //for (Context context = m_contextChangeLink; context != null; context = nextContext) //{ // nextContext = context.NextContext; // context.NextContext = null; //+ paranoia // context.Execute(); //} ContextChange context = _contextChangeLink; int contextCount = _contextChangeLinkCount; int contextIndex; for (contextIndex = 0; contextIndex <= (contextCount - 5); contextIndex += 5) { ContextChange context0 = context; nextContext = context0.NextContextChange; context0.NextContextChange = null; //+ paranoia ContextChange context1 = nextContext; nextContext = context1.NextContextChange; context1.NextContextChange = null; //+ paranoia ContextChange context2 = nextContext; nextContext = context2.NextContextChange; context2.NextContextChange = null; //+ paranoia ContextChange context3 = nextContext; nextContext = context3.NextContextChange; context3.NextContextChange = null; //+ paranoia ContextChange context4 = nextContext; nextContext = context4.NextContextChange; context4.NextContextChange = null; //+ paranoia context = nextContext; _threadPool.Add(new ContextChange[] { context0, context1, context2, context3, context4 }); } if (contextIndex != contextCount) { contextCount -= contextIndex; ContextChange[] contextArray = new ContextChange[contextCount]; contextIndex = 0; //for (; contextIndex < itemCount; /*context != null;*/ context = nextContext) //for (; context != null; context = nextContext) for (; contextIndex < contextCount; context = nextContext) { nextContext = context.NextContextChange; context.NextContextChange = null; //+ paranoia contextArray[contextIndex++] = context; } _threadPool.Add(contextArray); } //+ clear _contextChangeLink = null; _contextChangeLinkCount = 0; #endregion Process State-Change //+ if ((_isRebuildList == true) || (_listMaxWorkingFraction == fractionTime)) { _isRebuildList = false; listFractionTime = FillWorkingFractionArray <List <TElement> >(list, ref _listWorkingFractionArray, TimePrecision.ListWorkingFractionSize, ref listFractionTimeIndex, ref _listMaxWorkingFraction); } if ((_isRebuildLink == true) || (_linkMaxWorkingFraction == fractionTime)) { _isRebuildLink = false; linkFractionTime = FillWorkingFractionArray <LinkHead>(link, ref _linkWorkingFractionArray, TimePrecision.LinkWorkingFractionSize, ref linkFractionTimeIndex, ref _linkMaxWorkingFraction); } lastFractionTime = fractionTime; fractionTime = System.Math.Min(listFractionTime, linkFractionTime); _threadPool.Join(); } //+ advance time _isRebuildList = true; _isRebuildLink = true; time -= (TimePrecision.TimeScaler - lastFractionTime); _timesliceIndex++; if (_timesliceIndex >= TimesliceArraySize) { _timesliceIndex = 0; //System.Console.WriteLine("Timeline: ccycle"); //+ dehibernate #region Dehibernate for (LinkedListNode <Hibernate> hibernateNode = _hibernateList.First; hibernateNode != null; hibernateNode = hibernateNode.Next) { Hibernate hibernate = hibernateNode.Value; ulong newTime = (hibernate.Time -= TimesliceArrayTime); if (newTime < TimesliceArrayTime) { if (newTime < 0) { throw new System.InvalidOperationException(); //+ paranoia } //+ remove node _hibernateList.Remove(hibernateNode); //+ add to timeline System.Console.WriteLine("Timeline: Dehibernate {" + newTime.ToString() + "}"); Add(hibernate.Object, newTime); } else { hibernateNode.Value = hibernate; } } LinkBase lastObject = _hibernateLink; for (LinkBase @object = _hibernateLink; @object != null; @object = @object.NextLink) { ulong newTime = (@object.HibernateTime -= TimesliceArrayTime); if (newTime < TimesliceArrayTime) { if (newTime < 0) { throw new System.InvalidOperationException(); //+ paranoia } //+ remove node //lastObject = (m_hibernateLink != @object ? (lastObject.NextTimeLink = @object.NextTimeLink) : (m_hibernateLink = @object.NextTimeLink)); lastObject = (lastObject.NextLink = @object.NextLink); @object.NextLink = null; //+ paranoia //+ add to timeline System.Console.WriteLine("Timeline: Dehibernate {" + newTime.ToString() + "}"); Add(@object, newTime); } else { lastObject = @object; } } } #endregion Dehibernate } }
private static CurrentSpell ProtectorCommands(Player warrior) { ConsoleKeyInfo enter = new ConsoleKeyInfo(); Console.Clear(); var counter = 1; while (enter.Key != ConsoleKey.Enter) { if (enter.Key == ConsoleKey.DownArrow) { counter++; } else if (enter.Key == ConsoleKey.UpArrow) { counter--; } GameTitle.GetTitle(); string actionSelect = $"SELECT ACTION FOR {warrior.Name}"; string shieldSlam = $"SHIELD SLAM-- DEAL {warrior.Armor} DAMAGE, STUN OPPONENT FOR HIS TURN, COOLDOWN: 2"; string maceSwing = $"MACE SWING-- DAMAGE:{warrior.Damage * 1.5}, NO COOLDOWN"; string armorUp = $"ARMOR UP-- GAIN 200 ARMOR, NO COOLDOWN"; string hibernate = $"HIBERNATE-- HEAL FOR {warrior.HealthRegen*4}, TAKE 50% DAMAGE REDUCTION FOR OPPONENT'S TURN, COOLDOWN: 3"; Console.WriteLine("{0}", actionSelect); switch (counter) { case 1: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", "-> " + shieldSlam); Console.WriteLine("{0,2}", maceSwing); Console.WriteLine("{0,2}", armorUp); Console.WriteLine("{0,2}", hibernate); break; case 2: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", shieldSlam); Console.WriteLine("{0,2}", "-> " + maceSwing); Console.WriteLine("{0,2}", armorUp); Console.WriteLine("{0,2}", hibernate); break; case 3: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", shieldSlam); Console.WriteLine("{0,2}", maceSwing); Console.WriteLine("{0,2}", "-> " + armorUp); Console.WriteLine("{0,2}", hibernate); break; case 4: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", shieldSlam); Console.WriteLine("{0,2}", maceSwing); Console.WriteLine("{0,2}", armorUp); Console.WriteLine("{0,2}", "-> " + hibernate); break; default: if (counter == 5) { counter = 1; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", "-> " + shieldSlam); Console.WriteLine("{0,2}", maceSwing); Console.WriteLine("{0,2}", armorUp); Console.WriteLine("{0,2}", hibernate); break; } else if (counter == 0) { counter = 4; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("{0,2}", shieldSlam); Console.WriteLine("{0,2}", maceSwing); Console.WriteLine("{0,2}", armorUp); Console.WriteLine("{0,2}", "-> " + hibernate); break; } break; } enter = Console.ReadKey(); Console.Clear(); } var currentSpell = new CurrentSpell(); switch (counter) { case 1: var shieldSlam = new ShieldSlam(); currentSpell = shieldSlam.GetShieldSlam(warrior); break; case 2: var maceSwing = new MaceSwing(); currentSpell = maceSwing.GetMaceSwing(warrior); break; case 3: var armorUpSpell = new ArmorUp(); currentSpell = armorUpSpell.GetArmorUp(warrior); break; default: var hibernate = new Hibernate(); currentSpell = hibernate.GetHibernate(warrior); break; } return(currentSpell); }