static void ClearUCM() { /* Cls on the UCM zone described above. */ Crt.Window(WDM.UCM_X, WDM.UCM_Y, WDM.UCM_X2, WDM.UCM_Y2); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
static void TheDisplay(gamebook.Scenario SC) { /*This procedure sets up the BackPack display.*/ Crt.Window(WDM.EqpWin_X, WDM.EqpWin_Y, WDM.PCSWin_X2, WDM.InvWin_Y2); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); rpgtext.LovelyBox(Crt.Color.LightGray, WDM.EqpWin_X, WDM.EqpWin_Y, WDM.InvWin_X2, WDM.InvWin_Y2); Crt.TextColor(Crt.Color.Green); Crt.GotoXY(WDM.EqpWin_X + 2, WDM.EqpWin_Y2); Crt.TextColor(Crt.Color.LightGray); for (int t = 1; t <= WDM.EqpWin_WIDTH - 3; ++t) { Crt.Write((char)205); } Crt.TextColor(Crt.Color.Green); rpgtext.LovelyBox(Crt.Color.DarkGray, WDM.PCSWin_X, WDM.PCSWin_Y, WDM.PCSWin_X2, WDM.PCSWin_Y2); DisplayPCStats(SC); Crt.TextColor(Crt.Color.DarkGray); Crt.GotoXY(WDM.PCSWin_X, WDM.PCSWin_Y2 + 1); Crt.Write("/ - Mode d - Drop"); Crt.GotoXY(WDM.PCSWin_X, WDM.PCSWin_Y2 + 2); Crt.Write("[SPACE] - Default Item Action"); Crt.GotoXY(WDM.PCSWin_X, WDM.PCSWin_Y2 + 3); Crt.Write("[ESC] - Exit"); }
public static void RunGame() { rpgtext.SetKeyMap(); rpgmenus.RPGMenu menu = rpgmenus.CreateRPGMenu(Crt.Color.LightBlue, Crt.Color.Green, Crt.Color.LightGreen, 20, 8, 60, 23); rpgmenus.AddRPGMenuItem(menu, "Start New Game", 1); rpgmenus.AddRPGMenuItem(menu, "Load Saved Game", 2); rpgmenus.AddRPGMenuItem(menu, "Quit DeadCold", -1); int N = 0; do { //{ Set up the screen display. } Crt.ClrScr(); Crt.CursorOff(); //{ Get a selection from the menu. } N = rpgmenus.SelectMenu(menu, rpgmenus.RPMNoCancel); switch (N) { case 1: dcplay.StartGame(); break; case 2: dcplay.RestoreGame(); break; } }while (N > 0); }
public static void GameMessage(string msg, int x1, int y1, int x2, int y2, Crt.Color textColor, Crt.Color edgeColor) { //{ Take a text string, MSG, and prettyprint } //{ it within the box defined by X1,Y1 - X2,Y2. } //{ Set the background color to black.} Crt.TextBackground(Crt.Color.Black); //{ Print the border} if (edgeColor != Crt.Color.Black) { LovelyBox(edgeColor, x1, y1, x2, y2); } //{ Set the window to the desired print area, and clear everything.} Crt.Window(x1 + 1, y1 + 1, x2 - 1, y2 - 1); Crt.ClrScr(); //{ call the Delineate procedure to prettyprint it.} Crt.TextColor(textColor); Delineate(msg, x2 - x1 - 1, 1); //{ restore the window to its original, full dimensions.} Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
public static void Inventory(gamebook.Scenario SC, bool StartWithInv) { /*This procedure opens up the PC's inventory display,*/ /*and allows all the standard RPG options, such as*/ /*equipping items, dropping items, etc.*/ /*Set up the display.*/ TheDisplay(SC); /*Initialize misc values.*/ bool LC = true; /*Create the Equipment menu*/ CreateEqpMenu(SC); /*Create the Inventory menu*/ CreateInvMenu(SC); /*Display both menus*/ rpgmenus.DisplayMenu(EqpRPM); rpgmenus.DisplayMenu(InvRPM); /*Begin loop here.*/ while (LC) { /*Query the active menu.*/ if (StartWithInv) { LC = InvMenu(SC); } else { LC = EqpMenu(SC); } /*Switch to the other menu*/ StartWithInv = !StartWithInv; } /*Release the two menus that we created.*/ EqpRPM = null; InvRPM = null; /*Restore the display.*/ int X1 = Math.Min(WDM.EqpWin_X, Math.Min(WDM.DscWin_X, Math.Min(WDM.PCSWin_X, WDM.InvWin_X))); int Y1 = Math.Min(WDM.EqpWin_Y, Math.Min(WDM.DscWin_Y, Math.Min(WDM.PCSWin_Y, WDM.InvWin_Y))); int X2 = Math.Max(WDM.EqpWin_X2, Math.Max(WDM.DscWin_X2, Math.Max(WDM.PCSWin_X2, WDM.InvWin_X2))); int Y2 = Math.Max(WDM.EqpWin_Y2, Math.Max(WDM.DscWin_Y2, Math.Max(WDM.PCSWin_Y2, WDM.InvWin_Y2))); Crt.Window(X1, Y1, X2, Y2); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
public static void ClearMapArea() { //{Clear the map area. Pretty straight forward.} //{Set the clip area for this operation.} Crt.Window(MOX, MOY, MOX + MapDisplayWidth - 1, MOY + MapDisplayHeight - 1); //{Clear the current display area.} Crt.ClrScr(); //{Restore the original window.} Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
static void IntroStory(dcchars.DCChar PC) { //{Create an introductory story for the PC.} //{Display it in a special message window.} string Or1 = "You are from "; string Or2 = ", "; string Or3 = "."; string Ar2 = "Oddly, the station gave no response to your docking request. You pull into an open shuttle bay and prepare to disembark."; const int X1 = 15; const int Y1 = 5; const int X2 = 65; const int Y2 = 20; //{Set up the screen.} Crt.ClrScr(); rpgtext.LovelyBox(Crt.Color.LightBlue, X1, Y1, X2, Y2); Crt.Window(X1 + 1, Y1 + 1, X2 - 1, Y2 - 1); Crt.TextColor(Crt.Color.Green); //{Generate the PC's origin.} PC.bgOrigin = Or1 + RandomWorld() + Or2 + RandomWDesc() + Or3; //{Generate the PC's history.} //{Generate the PC's reason for arriving at DeadCold.} PC.bgArrival = RandomArrival(PC); //{Generate an introduction to the station.} //{Print the information.} rpgtext.Delineate(PC.bgOrigin, X2 - X1 - 1, 1); if (Crt.WhereX() != 1) { Crt.Write('\n'); } Crt.Write('\n'); rpgtext.Delineate(PC.bgArrival, X2 - X1 - 1, 1); if (Crt.WhereX() != 1) { Crt.Write('\n'); } Crt.Write('\n'); rpgtext.Delineate(Ar2, X2 - X1 - 1, 1); rpgtext.RPGKey(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); Crt.ClrScr(); }
static void PrintCap(string msg) { Crt.Window(WDM.UCM_X, WDM.UCM_Y, WDM.UCM_X2, WDM.UCM_Y + 2); Crt.ClrScr(); rpgtext.LovelyBox(Crt.Color.Blue, 3, 1, WDM.UCM_X2 - WDM.UCM_X - 2, 3); Crt.TextColor(Crt.Color.Green); int X = (WDM.UCM_X2 - WDM.UCM_X - msg.Length) / 2; if (X < 1) { X = 1; } Crt.GotoXY(X, 2); Crt.Write(msg); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
private static void InitConsole() { Crt.SetTitle("GameSrv WFC Screen v" + GameSrv.Version); Crt.SetWindowSize(90, 40); Crt.HideCursor(); Crt.ClrScr(); // WFC Screen Ansi.Write("[0;1;1;44;36m Last: [37mNo callers yet... [0;44;30m³ [1;36mRLogin: [37m0[36m On: [37mNo callers yet... [0;44;30m³ [1;36mTelnet: [37m0[36m Type: [37mNo callers yet... [0;44;30m³ [1;36mWebSocket: [37m0[36m [0;34mÚðð[1mStatus[0;34mððÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³[37m [32mTime: [37m[8C[32mDate: [37m[29C[34m³ °±²Û[1;44;37mGameSrv WFC Screen v" + GameSrv.Version + " [0;34m²±° ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ[37m Press [1;30m[[33mF1[30m][0m For Help or [1;30m[[33mQ[30m][0m To Quit"); Crt.FastWrite(DateTime.Now.ToString(_TimeFormatFooter).ToLower(), 9, 38, Crt.LightGreen); Crt.FastWrite(DateTime.Now.ToString("dddd MMMM dd, yyyy"), 23, 38, Crt.LightGreen); // Setup scrolling region with a window Crt.Window(3, 5, 88, 36); Crt.GotoXY(1, 32); }
static void RPMRefreshDesc(RPGMenu menu) { //{ Refresh the menu description box, if appropriate.} //{ Check to make sure that this menu has a description box, first off.} if (menu.dx1 > 0) { Crt.Window(menu.dx1 + 1, menu.dy1 + 1, menu.dx2 - 1, menu.dy2 - 1); Crt.ClrScr(); Crt.TextColor(menu.dTexColor); rpgtext.Delineate(RPMLocateByPosition(menu, menu.selectItem).desc, menu.dx2 - menu.dx1 - 1, 1); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); } }
static void AttemptHack(gamebook.Scenario SC, cwords.MPU MP, ref int Sec) { /* The player wants to hack this terminal. Give it a try, and hope */ /* there are no disasterous results... */ rpgtext.DCGameMessage("Attempting to hack " + cwords.MPUMan[MP.kind - 1].name + "..."); /* Do the animation for hacking. */ Crt.Window(WDM.MCM_X + 1, WDM.MCM_Y + 1, WDM.MCM_X2 - 1, WDM.MCM_Y2 - 1); Crt.ClrScr(); Crt.TextColor(Crt.Color.Blue); int N = rpgdice.Random(250) + 250; for (int t = 1; t <= N; ++t) { Crt.Write(rpgdice.Random(256).ToString("X2") + " "); } texfx.Delay(); N = rpgdice.Random(250) + 250; for (int t = 1; t <= N; ++t) { Crt.Write(rpgdice.Random(256).ToString("X2") + " "); } texfx.Delay(); /* Actually figure out if it worked. */ int R = rpgdice.RollStep(dcchars.PCTechSkill(SC.PC)); int T = Sec + cwords.MPUMan[MP.kind - 1].SecPass; if (R > cwords.MPUMan[MP.kind - 1].SecPass && R > T) { rpgtext.DCAppendMessage(" You did it."); Sec = R - cwords.MPUMan[MP.kind - 1].SecPass; } else { rpgtext.DCAppendMessage(" You failed."); if (R < T - 5) { MP.Attr = "X" + MP.Attr; if (R < T - 10) { gamebook.SetTrigger(SC, "ALARM"); } } } }
static void ValidateRegistration() { IniFile Ini = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "RMastermind.ini")); string Name = Ini.ReadString("Registration", "Name", ""); string Code = Ini.ReadString("Registration", "Code", "INVALID"); string ValidKey = StringUtils.MD5(_PreSalt, Name, _PostSalt); if (Code.ToLower() != ValidKey.ToLower()) { Crt.ClrScr(); Crt.WriteLn("Invalid Registration Key:"); Crt.WriteLn(" Got ........ '" + Code + "'"); Crt.WriteLn(" Expected ... '" + ValidKey + "'"); Crt.WriteLn("Fix your RMastermind.ini to continue"); Crt.ReadKey(); Environment.Exit(1); } }
static void DisplayPCStats(gamebook.Scenario SC) { /*Do a quick display of several of the PC's stats.*/ const int C1 = 2; const int C2 = 6; const int C3 = 12; const int C4 = 16; const int C5 = 22; const int C6 = 26; Crt.Window(WDM.PCSWin_X + 1, WDM.PCSWin_Y + 1, WDM.PCSWin_X2 - 1, WDM.PCSWin_Y2 - 1); Crt.ClrScr(); Crt.TextColor(Crt.Color.Blue); Crt.GotoXY(C1, 1); Crt.Write("H2H"); Crt.GotoXY(C3, 1); Crt.Write("Dmg"); Crt.GotoXY(C1, 2); Crt.Write("Gun"); Crt.GotoXY(C3, 2); Crt.Write("Dmg"); Crt.GotoXY(C5, 2); Crt.Write("Rng"); Crt.GotoXY(C1, 3); Crt.Write("Armor"); Crt.TextColor(Crt.Color.LightBlue); Crt.GotoXY(C2, 1); Crt.Write(dcchars.PCMeleeSkill(SC.PC).ToString()); Crt.GotoXY(C4, 1); Crt.Write(dcchars.PCMeleeDamage(SC.PC).ToString()); Crt.GotoXY(C2, 2); Crt.Write(dcchars.PCMissileSkill(SC.PC).ToString()); Crt.GotoXY(C4, 2); Crt.Write(dcchars.PCMissileDamage(SC.PC).ToString()); Crt.GotoXY(C6, 2); Crt.Write(dcchars.PCMissileRange(SC.PC).ToString()); Crt.GotoXY(C1 + 7, 3); Crt.Write(dcchars.PCArmorPV(SC.PC).ToString()); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); }
//{This unit contains all of the books which the player} //{can find over the course of the game.} public static void ReadBook(gamebook.Scenario SC, int N) { //{ Read book # N.} // Actually, it looks like this really isn't ready for prime time... since the Scenario and N aren't used yet. //{Set up the screen.} Crt.Window(WDM.Book_X, WDM.Book_Y, WDM.Book_X2, WDM.Book_Y2); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); //{Create the menu.} rpgmenus.RPGMenu menu = rpgmenus.CreateRPGMenu(Crt.Color.LightGray, Crt.Color.Green, Crt.Color.LightGreen, WDM.Book_X2 - 25, WDM.Book_Y + 4, WDM.Book_X2 - 5, WDM.Book_Y2 - 4); for (int i = 0; i < ThePages.Length; ++i) { rpgmenus.AddRPGMenuItem(menu, ThePages[i].name, i); } int p = -1; do { p = rpgmenus.SelectMenu(menu, rpgmenus.RPMNoCleanup); if (p != -1) { Crt.TextColor(Crt.Color.Black); Crt.TextBackground(Crt.Color.Yellow); Crt.Window(WDM.Book_X + 5, WDM.Book_Y + 1, WDM.Book_X + 32, WDM.Book_Y2 - 1); Crt.ClrScr(); Crt.Window(WDM.Book_X + 8, WDM.Book_Y + 3, WDM.Book_X + 30, WDM.Book_Y2 - 2); rpgtext.Delineate(ThePages[p].page, 21, 1); Crt.TextBackground(Crt.Color.Black); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); } }while (p >= 0); }
private static void InitConsole() { if (_FancyOutput) { //TODO Can do this without System.Windows.Forms reference? Crt.SetIcon(new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("GameSrv.GameSrv16+32.ico")).Handle); Crt.SetTitle("GameSrv WFC Screen v" + GameSrv.Version); Crt.SetWindowSize(90, 40); Crt.HideCursor(); Crt.ClrScr(); // WFC Screen Ansi.Write("[0;1;1;44;36m Last: [37mNo callers yet... [0;44;30m³ [1;36mRLogin: [37m0[36m On: [37mNo callers yet... [0;44;30m³ [1;36mTelnet: [37m0[36m Type: [37mNo callers yet... [0;44;30m³ [1;36mWebSocket: [37m0[36m [0;34mÚðð[1mStatus[0;34mððÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³³[37m[88C[34m³ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³[37m [32mTime: [37m[8C[32mDate: [37m[29C[34m³ °±²Û[1;44;37mGameSrv WFC Screen v" + GameSrv.Version + " [0;34m²±° ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ[37m Press [1;30m[[33mF1[30m][0m For Help or [1;30m[[33mQ[30m][0m To Quit"); Crt.FastWrite(DateTime.Now.ToString(_TimeFormatFooter).ToLower(), 9, 38, Crt.LightGreen); Crt.FastWrite(DateTime.Now.ToString("dddd MMMM dd, yyyy"), 23, 38, Crt.LightGreen); // Setup scrolling region with a window Crt.Window(3, 5, 88, 36); Crt.GotoXY(1, 32); } else { Crt.ClrScr(); } }
static void PlayScene(gamebook.Scenario SC) { /* This procedure holds the actual game loop. */ /* Note that at the } of this procedure, the scenario is */ /* deallocated. */ Crt.ClrScr(); texmaps.UpdatePOV(SC.gb.POV, SC.gb); texmaps.ApplyPOV(SC.gb.POV, SC.gb); texmaps.DisplayMap(SC.gb); gamebook.PCStatLine(SC); SC.PC.lastCmd = ' '; rpgtext.DCGameMessage("Welcome to the game."); do { SC.ComTime += 1; /* Set time triggers here. */ if (SC.ComTime % 720 == 0) { gamebook.SetTrigger(SC, "HOUR"); } else if (SC.ComTime % 120 == 0) { gamebook.SetTrigger(SC, "10MIN"); } else if (SC.ComTime % 12 == 0) { gamebook.SetTrigger(SC, "MINUTE"); } /*Update the PC's Status List.*/ statusfx.UpdateStatusList(ref SC.PC.SF); /*Check the PCs food status. A check is performed*/ /*every 10 minutes.*/ if (SC.ComTime % 120 == 81) { if (SC.PC.carbs > -10) { SC.PC.carbs -= 1; } if (SC.PC.carbs < 0) { rpgtext.DCGameMessage("You are starving!"); } else if (SC.PC.carbs < 10) { rpgtext.DCGameMessage("You are hungry."); } gamebook.PCStatLine(SC); } /* Check for PC regeneration. A check is performed every minute. */ /* The PC does _not_ regenerate while poisoned. Ouch. */ if (SC.ComTime % 12 == 0) { /*See if the PC gets any HPs back this click...*/ if (SC.PC.HP < SC.PC.HPMax && plotbase.NAttValue(SC.PC.SF, statusfx.NAG_StatusChange, statusfx.SEF_Poison) == 0) { if (gamebook.NumberOfActions(SC.ComTime / 12, dcchars.PCRegeneration(SC.PC)) > 0) { SC.PC.HP += gamebook.NumberOfActions(SC.ComTime / 12, dcchars.PCRegeneration(SC.PC)); /*If the PC is starving and injured, perminant damage to health may result.*/ if (SC.PC.carbs < 0 && rpgdice.Random(Math.Abs(SC.PC.carbs)) > rpgdice.Random(SC.PC.stat[8 - 1]) && SC.PC.HPMax > 10) { SC.PC.HPMax -= 1; rpgtext.DCGameMessage("You feel seriously ill."); } if (SC.PC.HP > SC.PC.HPMax) { SC.PC.HP = SC.PC.HPMax; } gamebook.PCStatLine(SC); } } /*Check for PC MP restoration.*/ if (SC.PC.MP < SC.PC.MPMax) { SC.PC.MP += gamebook.NumberOfActions(SC.ComTime / 12, dcchars.PCRestoration(SC.PC)); if (SC.PC.MP > SC.PC.MPMax) { SC.PC.MP = SC.PC.MPMax; } gamebook.PCStatLine(SC); } } /*Check for random monsters every 5 minutes.*/ if (SC.ComTime % rpgtext.PLAY_MonsterTime == 0) { charts.WanderingCritters(SC); } /* Check for spontaneous identification of items every hour. */ if (SC.ComTime % 720 == 553) { pcaction.ScanUnknownInv(SC); } /*If the player gets an action this second, use it.*/ for (int t = 1; t <= gamebook.NumberOfActions(SC.ComTime, dcchars.PCMoveSpeed(SC.PC)); ++t) { DoPCAction(SC); /* If QUIT was the command, or if the PC is dead, */ /* break this loop. */ if (SC.PC.lastCmd == rpgtext.KMap[26].key || SC.PC.HP <= 0) { break; } plotline.HandleTriggers(SC); SC.gb.POV.range = dcchars.PCVisionRange(SC.PC); } /* If a QUIT request wan't recieved, handle clouds and critters. */ if (SC.PC.lastCmd != rpgtext.KMap[26].key) { /*Cloud handling. Happens every 4 seconds.*/ if (SC.ComTime % 4 == 1) { cbrain.BrownianMotion(SC); } /*Critter handling*/ critters.Critter Cr = SC.CList; while (Cr != null) { /*Save the position of the next critter,*/ /*since the critter we're processing might*/ /*accidentally kill itself during its move.*/ SC.CA2 = Cr.next; for (int t = 1; t <= gamebook.NumberOfActions(SC.ComTime, critters.MonMan[Cr.crit - 1].Speed); ++t) { cbrain.CritterAction(SC, ref Cr); if (Cr == null) { break; } } Cr = SC.CA2; if (SC.PC.HP < 1) { Cr = null; } } } }while (SC.PC.lastCmd != rpgtext.KMap[26].key && SC.PC.HP > 0); if (SC.PC.HP < 1) { rpgtext.DCGameMessage("Game Over."); rpgtext.GamePause(); string fname = "savegame/" + SC.PC.name + ".txt"; if (rpgtext.PLAY_DangerOn) { File.Delete(fname); } } }
public static dcchars.DCChar RollNewChar() { //{We're going to generate a new game character from scratch.} //{Return NIL if the character creation process was cancelled.} const string instructions = "Select one of the avaliable jobs from the menu. Press ESC to reroll stats, or select Cancel to exit."; //var // pc: dccharptr; // opt: rpgmenuptr; {The menu holding avaliable jobs.} // t,tt: Integer; {Loop counters} // q: boolean; {Apparently, for this procedure, I've forgotten about useful variable names. It's hot and I'm tired.} // I: DCItemPtr; int t, tt; //{Allocate memory for the character.} dcchars.DCChar PC = new dcchars.DCChar(); //{Initilize Job to -1} PC.job = -1; //{Clear the screen} Crt.ClrScr(); //{Display the stat names} Crt.TextColor(Crt.Color.Cyan); for (t = 1; t <= 8; ++t) { Crt.GotoXY(12, t * 2 + 3); Crt.Write(dcchars.StatName[t - 1] + " :"); } //{Start a loop. We'll stay in the loop until a character is selected.} while (PC.job == -1) { //{Give a short message on how to use the character generator} rpgtext.GameMessage(instructions, 2, 1, 79, 4, Crt.Color.Green, Crt.Color.LightBlue); //{Set the text color} Crt.TextColor(Crt.Color.White); //{Roll the character's stats.} RollGHStats(PC, 100 + rpgdice.Random(20)); for (t = 1; t <= 8; ++t) { //{display the stat onscreen.} Crt.GotoXY(35, t * 2 + 3); Crt.Write(" "); Crt.GotoXY(35, t * 2 + 3); Crt.Write(PC.stat[t - 1].ToString()); } //{determine which jobs are open to this character, and} //{add them to our RPGMenu.} //{First, allocate the menu.} rpgmenus.RPGMenu opt = rpgmenus.CreateRPGMenu(Crt.Color.LightBlue, Crt.Color.Blue, Crt.Color.LightCyan, 46, 7, 65, 17); //{Initialize the description elements.} opt.dx1 = 2; opt.dx2 = 79; opt.dy1 = 20; opt.dy2 = 24; opt.dTexColor = Crt.Color.Green; for (t = 1; t <= dcchars.NumJobs; ++t) { //{Initialize q to true} bool q = true; //{Check each stat} for (tt = 1; tt <= 8; ++tt) { if (PC.stat[tt - 1] < dcchars.JobStat[t - 1, tt - 1]) { q = false; } } //{If q is still true, this job may be chosen.} if (q) { rpgmenus.AddRPGMenuItem(opt, dcchars.JobName[t - 1], t, dcchars.JobDesc[t - 1]); } } //{Get the jobs in alphabetical order} rpgmenus.RPMSortAlpha(opt); //{Add a CANCEL to the list} rpgmenus.AddRPGMenuItem(opt, " Cancel", 0, null); //{Ask for a selection} PC.job = rpgmenus.SelectMenu(opt, rpgmenus.RPMNoCleanup); PC.m = null; } //{If the player selected cancel, dispose of the PC record.} if (PC.job == 0) { PC = null; } else { //{Copy skill ranks} for (t = 1; t <= dcchars.NumSkill; t++) { PC.skill[t - 1] = dcchars.JobSkill[PC.job - 1, t - 1]; } //{Set HP, HPMax, and other initial values.} PC.HPMax = PC.stat[dcchars.STAT_Toughness] + dcchars.JobHitDie[PC.job - 1] + dcchars.BaseHP; PC.HP = PC.HPMax; PC.MPMax = PC.stat[dcchars.STAT_Willpower] / 2 + dcchars.JobMojoDie[PC.job - 1] + rpgdice.Random(dcchars.JobMojoDie[PC.job - 1]); PC.MP = PC.MPMax; PC.target = null; PC.carbs = 50; PC.lvl = 1; PC.XP = 0; PC.repCount = 0; PC.inv = null; for (t = 1; t <= dcchars.NumEquipSlots; ++t) { PC.eqp[t - 1] = null; } PC.SF = null; PC.spell = null; //{Give some basic equipment.} DoleEquipment(PC); //{Add the PC's meals.} for (t = 1; t <= 5; ++t) { dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; I.icode = JobXFood[PC.job, rpgdice.Random(10)]; I.charge = 1; dcitems.MergeDCItem(ref PC.inv, I); } //{Add the PC's snacks.} int total = rpgdice.Random(5) + 1; for (t = 1; t <= total; ++t) { dcitems.DCItem I = new dcitems.DCItem(); I.ikind = dcitems.IKIND_Food; //{Decide upon what kind of food to give, based on job.} if (rpgdice.Random(3) == 2) { I.icode = JobXFood[0, rpgdice.Random(10)]; } else { I.icode = JobXFood[PC.job, rpgdice.Random(10)]; } I.charge = rpgdice.Random(3) + 1; dcitems.MergeDCItem(ref PC.inv, I); } //{ Input a name. } rpgtext.GameMessage("NAME: ", 2, 1, 79, 4, Crt.Color.LightGreen, Crt.Color.LightBlue); Crt.GotoXY(9, 2); Crt.CursorOn(); PC.name = rpgtext.ReadLine(); Crt.CursorOff(); if (PC.name != "") { //{ Generate an introduction. } IntroStory(PC); //{Add spells, if appropriate.} if (PC.skill[dcchars.SKILL_LearnSpell] > 0) { SelectPCSpells(PC); } } else { PC = null; } } return(PC); }
private static void AnsiCommand(char ACommand) { lock (_Lock) { int Colour = 0; int X = 0; int Y = 0; int Z = 0; switch (ACommand) { case 'A': // CSI n A - Moves the cursor n (default 1) cells up. If the cursor is already at the edge of the screen, this has no effect. Y = Math.Max(1, _AnsiParams.Dequeue()); Y = Math.Max(1, Crt.WhereY() - Y); Crt.GotoXY(Crt.WhereX(), Y); break; case 'B': // CSI n B - Moves the cursor n (default 1) cells down. If the cursor is already at the edge of the screen, this has no effect. Y = Math.Max(1, _AnsiParams.Dequeue()); Y = Math.Min(Crt.WindRows, Crt.WhereY() + Y); Crt.GotoXY(Crt.WhereX(), Y); break; case 'C': // CSI n C - Moves the cursor n (default 1) cells right. If the cursor is already at the edge of the screen, this has no effect. X = Math.Max(1, _AnsiParams.Dequeue()); X = Math.Min(Crt.WindCols, Crt.WhereX() + X); Crt.GotoXY(X, Crt.WhereY()); break; case 'D': // CSI n D - Moves the cursor n (default 1) cells left. If the cursor is already at the edge of the screen, this has no effect. X = Math.Max(1, _AnsiParams.Dequeue()); X = Math.Max(1, Crt.WhereX() - X); Crt.GotoXY(X, Crt.WhereY()); break; case 'E': // CSI n E - Moves cursor to beginning of the line n (default 1) lines down. Y = Math.Max(1, _AnsiParams.Dequeue()); Y = Math.Min(Crt.WindRows, Crt.WhereY() + Y); Crt.GotoXY(1, Y); break; case 'F': // CSI n F - Moves cursor to beginning of the line n (default 1) lines up. Y = Math.Max(1, _AnsiParams.Dequeue()); Y = Math.Max(1, Crt.WhereY() - Y); Crt.GotoXY(1, Y); break; case 'f': // CSI y ; x f or CSI ; x f or CSI y ; f - Moves the cursor to row y, column x. The values are 1-based, and default to 1 (top left corner) if omitted. A sequence such as CSI ;5f is a synonym for CSI 1;5f as well as CSI 17;f is the same as CSI 17f and CSI 17;1f AnsiCommand('H'); // Cheat and just call the more common H equivalent break; case 'G': // CSI n G - Moves the cursor to column n. X = Math.Max(1, _AnsiParams.Dequeue()); if ((X >= 1) && (X <= Crt.WindCols)) { Crt.GotoXY(X, Crt.WhereY()); } break; case 'H': // CSI y ; x H or CSI ; x H or CSI y ; H - Moves the cursor to row y, column x. The values are 1-based, and default to 1 (top left corner) if omitted. A sequence such as CSI ;5H is a synonym for CSI 1;5H as well as CSI 17;H is the same as CSI 17H and CSI 17;1H while (_AnsiParams.Count < 2) { _AnsiParams.Enqueue(1); // Make sure we have enough parameters } Y = Math.Max(1, _AnsiParams.Dequeue()); X = Math.Max(1, _AnsiParams.Dequeue()); Crt.GotoXY(X, Y); break; case 'h': // CSI n h // n = 7 enables auto line wrap when writing to last column of screen (which is on by default so we ignore the sequence) X = _AnsiParams.Dequeue(); switch (X) { case 7: /* Ignore */ break; case 25: Crt.ShowCursor(); break; } break; case 'J': // CSI n J - Clears part of the screen. If n is zero (or missing), clear from cursor to end of screen. If n is one, clear from cursor to beginning of the screen. If n is two, clear entire screen (and moves cursor to upper left on MS-DOS ANSI.SYS). switch (_AnsiParams.Dequeue()) { case 0: Crt.ClrEos(); break; case 1: Crt.ClrBos(); break; case 2: Crt.ClrScr(); break; } break; case 'K': // CSI n K - Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change. switch (_AnsiParams.Dequeue()) { case 0: Crt.ClrEol(); break; case 1: Crt.ClrBol(); break; case 2: Crt.ClrLine(); break; } break; case 'L': // CSI n L - Insert n new lines, pushing the current line and those below it down Y = Math.Max(1, _AnsiParams.Dequeue()); Crt.InsLine(Y); break; case 'l': // CSI n l // n = 7 disables auto line wrap when writing to last column of screen (we dont support this) X = _AnsiParams.Dequeue(); switch (X) { case 7: /* Ignore */ break; case 25: Crt.HideCursor(); break; } break; case 'M': // CSI n M - Delete n lines, pulling the lines below the deleted lines up Y = Math.Max(1, _AnsiParams.Dequeue()); Crt.DelLine(Y); break; case 'm': // CSI n [;k] m - Sets SGR parameters. After CSI can be zero or more parameters separated with ;. With no parameters, CSI m is treated as CSI 0 m (reset / normal), which is typical of most of the ANSI escape sequences. while (_AnsiParams.Count > 0) { X = _AnsiParams.Dequeue(); switch (X) { case 0: // Reset / Normal (all attributes off) Crt.NormVideo(); break; case 1: // Intensity: Bold Crt.HighVideo(); break; case 2: // Intensity: Faint (not widely supported) break; case 3: // Italic: on (not widely supported) break; case 4: // Underline: Single break; case 5: // Blink: Slow (< 150 per minute) Crt.TextAttr |= Crt.Blink; Crt.SetBlinkRate(500); break; case 6: // Blink: Rapid (>= 150 per minute) Crt.TextAttr |= Crt.Blink; Crt.SetBlinkRate(250); break; case 7: // Image: Negative (swap foreground and background) Crt.ReverseVideo(); break; case 8: // Conceal (not widely supported) _AnsiAttr = Crt.TextAttr; Crt.Conceal(); break; case 21: // Underline: Double (not widely supported) break; case 22: // Intensity: Normal (not widely supported) Crt.LowVideo(); break; case 24: // Underline: None break; case 25: // Blink: off Crt.TextAttr &= ~Crt.Blink; break; case 27: // Image: Positive (handle the same as negative Crt.ReverseVideo(); break; case 28: // Reveal (conceal off) Crt.TextAttr = _AnsiAttr; break; case 30: // Set foreground color, normal intensity case 31: case 32: case 33: case 34: case 35: case 36: case 37: Colour = ANSI_COLORS[X - 30]; if (Crt.TextAttr % 16 > 7) { Colour += 8; } Crt.TextColor(Colour); break; case 40: // Set background color, normal intensity case 41: case 42: case 43: case 44: case 45: case 46: case 47: Colour = ANSI_COLORS[X - 40]; Crt.TextBackground(Colour); break; } } break; case 'n': // CSI X n // n = 5 Device status report (reply with \x1B[0n to report "ready, no malfunction detected") // n = 6 Reports the cursor position to the application as (as though typed at the keyboard) ESC[n;mR, where n is the row and m is the column. (May not work on MS-DOS.) // n = 255 Reports the bottom right cursor position (essentially the screen size) X = _AnsiParams.Dequeue(); switch (X) { case 5: RaiseESC5nEvent(); break; case 6: RaiseESC6nEvent(); break; case 255: RaiseESC255nEvent(); break; } break; case 'Q': // CSI cp ; x ; y Q - NON-STANDARD fTelnet EXTENSION - Changes the current font to CodePage=cp, Width=x, Height=y while (_AnsiParams.Count < 3) { _AnsiParams.Enqueue(0); // Make sure we have enough parameters } X = _AnsiParams.Dequeue(); Y = _AnsiParams.Dequeue(); Z = _AnsiParams.Dequeue(); RaiseESCQEvent(X, Y, Z); break; case 'S': // CSI n S - Scroll whole page up by n (default 1) lines. New lines are added at the bottom. (not ANSI.SYS) Y = Math.Max(1, _AnsiParams.Dequeue()); Crt.ScrollUpScreen(Y); break; case 's': // CSI s - Saves the cursor position. _SavedX = Crt.WhereX(); _SavedY = Crt.WhereY(); break; case 'T': // CSI n T - Scroll whole page down by n (default 1) lines. New lines are added at the top. (not ANSI.SYS) Y = Math.Max(1, _AnsiParams.Dequeue()); Crt.ScrollDownWindow(Y); break; case 'u': // CSI u - Restores the cursor position. if ((_SavedX > 0) && (_SavedY > 0)) { Crt.GotoXY(_SavedX, _SavedY); } break; } } }
//{*** GENERAL IO ROUTINES ***} public static void PCStatLine(Scenario SC) { Crt.Window(WDM.PCStat_X, WDM.PCStat_Y, WDM.PCStat_X2, WDM.PCStat_Y); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); //{Print data on status effects.} Crt.GotoXY(WDM.PCStat_X, WDM.PCStat_Y); //{ First, if player is starving, show that. } if (SC.PC.carbs < 0) { Crt.TextColor(Crt.Color.LightRed); Crt.Write("Sta"); } else if (SC.PC.carbs < 10) { Crt.TextColor(Crt.Color.Yellow); Crt.Write("Hgr"); } int t; for (t = 0; t < PCSLNumSFX; ++t) { if (Crt.WhereX() < 15 && plotbase.NAttValue(SC.PC.SF, statusfx.NAG_StatusChange, SFXVal[t]) != 0) { Crt.TextColor(SFXColor[t]); Crt.Write(SFXChar[t]); } } int HP = SC.PC.HP; if (HP < 0) { HP = 0; } else if (HP > 999) { HP = 999; } Crt.TextColor(Crt.Color.Green); Crt.GotoXY(18, WDM.PCStat_Y); Crt.Write("HP:"); Crt.TextColor(StatusColor(SC.PC.HPMax, SC.PC.HP)); Crt.Write(HP.ToString()); HP = SC.PC.MP; if (HP < 0) { HP = 0; } else if (HP > 999) { HP = 999; } Crt.TextColor(Crt.Color.Green); Crt.GotoXY(25, WDM.PCStat_Y); Crt.Write("MP:"); Crt.TextColor(StatusColor(SC.PC.MPMax, SC.PC.MP)); Crt.Write(HP.ToString()); for (t = 0; t < 8; ++t) { Crt.TextColor(Crt.Color.Green); Crt.GotoXY(33 + t * 6, WDM.PCStat_Y); Crt.Write(dcchars.StatAbbrev[t] + ":"); HP = dcchars.CStat(SC.PC, t); if (HP < SC.PC.stat[t]) { Crt.TextColor(Crt.Color.Red); } else if (HP > SC.PC.stat[t]) { Crt.TextColor(Crt.Color.LightBlue); } else { Crt.TextColor(Crt.Color.LightGreen); } if (HP > 99) { HP = 99; } if (HP < 10) { Crt.Write(' '); } Crt.Write(HP.ToString()); } }
public static void DisplayMenu(RPGMenu menu) { //{ Display the menu on the screen.} //{ Error check- make sure the menu has items in it.} if (menu.firstItem == null) { return; } //{ Check to see if the user wants a border. If so, draw it.} if (menu.borderColor != Crt.Color.Black) { //{ Draw a LovelyBox first for the menu.} rpgtext.LovelyBox(menu.borderColor, menu.x1, menu.y1, menu.x2, menu.y2); } //{ Next draw a LovelyBox for the item description, if applicable.} if (menu.dx1 > 0) { rpgtext.LovelyBox(menu.dBorColor, menu.dx1, menu.dy1, menu.dx2, menu.dy2); } //{ Display each menu item.} //{ Open an appropriately sized window and clear that area.} Crt.Window(menu.x1 + 1, menu.y1 + 1, menu.x2 - 1, menu.y2 - 1); Crt.ClrScr(); //{ Calculate the width and the height of the menu.} int width = menu.x2 - menu.x1 - 1; int height = menu.y2 - menu.y1 - 1; //{ Locate the top of the menu.} RPGMenuItem a = RPMLocateByPosition(menu, menu.topItem); for (int t = 1; t <= height; ++t) { //{ If we're at the currently selected item, highlight it.} if (((t + menu.topItem - 1) == menu.selectItem) && menu.active) { Crt.TextColor(menu.selColor); } else { Crt.TextColor(menu.itemColor); } Crt.GotoXY(1, t); Crt.Write(a.msg.Substring(0, Math.Min(width, a.msg.Length))); a = a.next; //{Check to see if we've prematurely encountered the end of the list.} if (a == null) { break; } } //{Restore the window to its regular size.} Crt.Window(1, 1, WDM.Book_WIDTH, WDM.CON_HEIGHT); //{If there's an associated Desc field, display it now.} RPMRefreshDesc(menu); }
public static void HandyMap(gamebook.Scenario SC) { /* The PC is about to use his HANDYMAP automatic mapping system. */ /* Start by doing the HANDYMAP case display. */ const int X1 = WDM.HM_X; const int X2 = WDM.HM_X2; const int Y1 = WDM.HM_Y; const int Y2 = WDM.HM_Y2; Crt.Window(X1, Y1, X2, Y2); Crt.ClrScr(); Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); rpgtext.LovelyBox(Crt.Color.Red, X1, Y1, X2, Y2); rpgtext.LovelyBox(Crt.Color.LightGray, X1 + 1, Y1 + 2, X2 - 1, Y2 - 1); Crt.TextColor(Crt.Color.LightRed); Crt.TextBackground(Crt.Color.Black); Crt.GotoXY(X1 + 1, Y1 + 1); Crt.Write("X HANDYMAP v3.14"); /* Next, go through the map in 16 x 16 blocks. */ for (int X = 1; X <= texmodel.XMax / 8; ++X) { for (int Y = 1; Y < texmodel.YMax / 16; ++Y) { int Rev = 0; char C = ' '; for (int XX = X * 8 - 7; XX <= X * 8; ++XX) { for (int YY = Y * 16 - 15; YY <= Y * 16; ++YY) { /* If this tile has been seen by the PC, increment */ /* the visible counter. */ if (SC.gb.map[XX - 1, YY - 1].visible) { Rev += 1; /* If this tile contains a special tile, */ /* store it here. */ switch (SC.gb.map[XX - 1, YY - 1].terr) { case texmaps.TransitLeft: C = '<'; break; case texmaps.TransitRight: C = '>'; break; case texmaps.TransitUp: C = '^'; break; case texmaps.TransitDown: C = 'v'; break; case texmaps.PilotsChair: C = 'S'; break; case texmaps.ForceField: C = 'F'; break; case texmaps.ForceFieldGenerator: C = 'g'; break; } } } } /* Set colors - if this is the map block containing the */ /* pilot, reverse the colors. */ if (SC.PC.m.x > (X - 1) * 8 && SC.PC.m.x <= X * 8 && SC.PC.m.y > (Y - 1) * 16 && SC.PC.m.y <= Y * 16) { Crt.TextColor(Crt.Color.Black); Crt.TextBackground(Crt.Color.LightGreen); } else { Crt.TextColor(Crt.Color.Green); Crt.TextBackground(Crt.Color.Black); } /* Print the decided-upon character. */ Crt.GotoXY(X + 1 + X1, Y + 2 + Y1); if (C != ' ') { Crt.Write(C); } else if (Rev > 75) { Crt.Write('#'); } else if (Rev > 50) { Crt.Write('='); } else if (Rev > 25) { Crt.Write('-'); } else if (Rev > 0) { Crt.Write('.'); } else { Crt.Write(' '); } } } /* Wait for a keypress. */ rpgtext.RPGKey(); }
public static int SelectMenu(RPGMenu menu, int mode) { //{ This function will allow the user to browse through the menu and will} //{ return a value based upon the user's selection.} //{The menu is now active!} menu.active = true; //{Show the menu to the user.} DisplayMenu(menu); //{Initialize UK and r} bool UK = false; int r = -1; char getit = '\0'; //{Start the loop. Remain in this loop until either the player makes a selection} //{or cancels the menu using the ESC key.} do { //{Read the input from the keyboard.} getit = rpgtext.RPGKey(); //{Certain keys need processing- if so, process them.} switch (getit) { //{Selection Movement Keys} case (char)72: case '8': RPMUpKey(menu); break; case (char)80: case '2': RPMDownKey(menu); break; //{If we recieve an ESC, better check to make sure we're in a} //{cancelable menu. If not, convert the ESC to an unused key.} case (char)27: if (mode == RPMNoCancel) { getit = 'Q'; } break; } //{Check to see if a special MENU KEY has been pressed.} if (menu.firstKey != null) { RPGMenuKey m = menu.firstKey; while (m != null) { if (getit == m.k) { UK = true; r = m.value; break; } m = m.next; } } //{Check for a SPACE or ESC.} }while ((getit != ' ') && (getit != (char)27) && !UK); //{The menu is no longer active.} menu.active = false; //{We have to send back a different value depending upon whether a selection} //{was made or the menu was cancelled. If an item was selected, return its} //{value field. The value always returned by a cancel will be -1.} //{If a MenuKey was pressed, r already contains the right value.} if (getit == ' ') { r = RPMLocateByPosition(menu, menu.selectItem).value; } if (mode != RPMNoCleanup) { //{Remove the menu from the display. I'm gonna use Window for this, since} //{ClrScr in this language doesn't take paramters. Bummer.} //{Check to see whether or not a border was used.} if (menu.borderColor == Crt.Color.Black) { Crt.Window(menu.x1 + 1, menu.y1 + 1, menu.x2 - 1, menu.y2 - 1); Crt.ClrScr(); } else { Crt.Window(menu.x1, menu.y1, menu.x2, menu.y2); Crt.ClrScr(); } //{If there's an associated description box, clear that too.} if (menu.dx1 > 0) { Crt.Window(menu.dx1, menu.dy1, menu.dx2, menu.dy2); Crt.ClrScr(); } } //{Reset the window to normal values} Crt.Window(1, 1, WDM.CON_WIDTH, WDM.CON_HEIGHT); return(r); }
public static void PlayGame() { string saveFile = "deadcold.sav"; if (File.Exists(saveFile)) { StreamReader r = File.OpenText(saveFile); LoadLogon(r); r.Close(); } SetKeyMap(); Crt.TextColor(Crt.Color.Green); Crt.ClrScr(); rpgmenus.RPGMenu menu = rpgmenus.CreateRPGMenu(Crt.Color.White, Crt.Color.Green, Crt.Color.LightGreen, 5, 3, 60, 14); rpgmenus.BuildFileMenu(menu, "*.*"); string filename = rpgmenus.SelectFile(menu, rpgmenus.RPMNoCancel); Crt.Write("You selected the file: "); Crt.Write(filename); Crt.Write("\n"); Crt.Write("You are about to play the game.\n"); rpgmenus.RPGMenu items = rpgmenus.CreateRPGMenu(Crt.Color.Blue, Crt.Color.Red, Crt.Color.White, 15, 12, 40, 20); rpgmenus.AddRPGMenuItem(items, "World", 5); rpgmenus.AddRPGMenuItem(items, "Hello", 3); rpgmenus.AddRPGMenuItem(items, "Dingus", 2); rpgmenus.AddRPGMenuItem(items, "Cake", 1); rpgmenus.AddRPGMenuItem(items, "ZooFlower", 4); rpgmenus.AddRPGMenuKey(items, 'd', 3); rpgmenus.AddRPGMenuKey(items, 'w', 5); rpgmenus.RPMSortAlpha(items); int value = rpgmenus.SelectMenu(items, rpgmenus.RPMNormal); Crt.Write("You selected the value: "); Crt.Write(value.ToString()); Crt.Write("\n"); bool done = false; while (!done) { Crt.TextColor(Crt.Color.White); Crt.Write("Would you like to quit?\n(Y/N):"); if (YesNo()) { done = true; Crt.TextColor(Crt.Color.Red); Crt.Write("\nOkay... the game is over."); } else { GameMessage("nOh, goody, you've deaalsdjflaskdjfdecided to keep playing the game... That is very good news, we should play and play and play..", 5, 5, 24, 12, Crt.Color.LightGreen, Crt.Color.Blue); RPGKey(); Crt.ClrScr(); GamePause(); Crt.TextColor(Crt.Color.LightGreen); Crt.Write("This is a very long line that is meant to wrap at least once... blah blhal blabhlhaslkdfasdfjalskdfjlakdjf\n\n"); char c; do { c = RPGKey(); Crt.Write(c.ToString()); }while (c != '!'); } } StreamWriter f = File.CreateText(saveFile); SaveLogon(f); f.Close(); }
static void Main(string[] args) { // Check command-line parameters foreach (string Arg in args) { switch (Arg.ToLower()) { case "24h": _TimeFormatFooter = "HH:mm"; break; case "simple": _FancyOutput = false; break; } } // Remove old "stop requested" file if (File.Exists(StringUtils.PathCombine(ProcessUtils.StartupPath, "gamesrvconsole.stop"))) { FileUtils.FileDelete(StringUtils.PathCombine(ProcessUtils.StartupPath, "gamesrvconsole.stop")); } // Add connection types to counter _ConnectionCounts[ConnectionType.RLogin] = 0; _ConnectionCounts[ConnectionType.Telnet] = 0; _ConnectionCounts[ConnectionType.WebSocket] = 0; // Initialize the screen InitConsole(); Write(Globals.Copyright, false); // Check if running as root if (Globals.StartedAsRoot) { WriteLn("", false); WriteLn("*** WARNING: Running GameSrv as root is NOT recommended ***", false); WriteLn("", false); WriteLn("A safer alternative to running GameSrv as root is to run it via 'privbind'", false); WriteLn("This will ensure GameSrv is able to bind to ports in the < 1024 range, but", false); WriteLn("it will run as a regular unprivileged program in every other way", false); WriteLn("", false); WriteLn("See start.sh for an example of the recommended method to start GameSrv", false); WriteLn("", false); } // Init GameSrv _GameSrv = new GameSrv(); _GameSrv.AggregatedStatusMessageEvent += new EventHandler <StringEventArgs>(GameSrv_AggregatedStatusMessageEvent); _GameSrv.LogOnEvent += new EventHandler <NodeEventArgs>(GameSrv_LogOnEvent); _GameSrv.Start(); // Main program loop int LastMinute = -1; int LastSecond = -1; bool Quit = false; while (!Quit) { while (!Crt.KeyPressed()) { Crt.Delay(100); if (DateTime.Now.Minute != LastMinute) { UpdateTime(); LastMinute = DateTime.Now.Minute; } if ((DateTime.Now.Second % 2 == 0) && (DateTime.Now.Second != LastSecond)) { LastSecond = DateTime.Now.Second; if (File.Exists(StringUtils.PathCombine(ProcessUtils.StartupPath, "gamesrvconsole.stop"))) { FileUtils.FileDelete(StringUtils.PathCombine(ProcessUtils.StartupPath, "gamesrvconsole.stop")); _GameSrv.Stop(); _GameSrv.Dispose(); Quit = true; break; } } } if (Crt.KeyPressed()) { char Ch = Crt.ReadKey(); switch (Ch.ToString().ToUpper()) { case "\0": char Ch2 = Crt.ReadKey(); if (Ch2 == ';') // F1 { WriteLn("", false); WriteLn("GameSrv WFC Screen Help", false); WriteLn("-=-=-=-=-=-=-=-=-=-=-=-", false); WriteLn("F1 = Help (this screen)", false); WriteLn("C = Clear (clear the status window)", false); WriteLn("P = Pause (reject new connections, leave existing connections alone)", false); WriteLn("S = Setup (launch the config program)", false); WriteLn("Q = Quit (shut down and terminate existing connections)", false); WriteLn("", false); } break; case "C": Crt.ClrScr(); if (_FancyOutput) { Crt.GotoXY(1, 32); } break; case "P": _GameSrv.Pause(); break; case "S": Process.Start(StringUtils.PathCombine(ProcessUtils.StartupPath, "GameSrvConfig.exe")); break; case "Q": // Check if we're already stopped (or are stopping) if ((_GameSrv.Status != ServerStatus.Stopped) && (_GameSrv.Status != ServerStatus.Stopping)) { int ConnectionCount = _GameSrv.ConnectionCount; if (ConnectionCount > 0) { WriteLn("", false); WriteLn("There are " + ConnectionCount.ToString() + " active connections.", false); WriteLn("Are you sure you want to quit [y/N]: ", false); WriteLn("", false); Ch = Crt.ReadKey(); if (Ch.ToString().ToUpper() != "Y") { WriteLn("", false); WriteLn("Cancelling quit request.", false); WriteLn("", false); continue; } } } _GameSrv.Stop(); _GameSrv.Dispose(); Quit = true; break; } } } Environment.Exit(0); }
public static void Start() { // Initialize the screen Crt.ClrScr(); StatusText(Helpers.Copyright, false); // Check if running as root if (Helpers.StartedAsRoot) { StatusText("", false); StatusText("*** WARNING: Running GameSrv as root is NOT recommended ***", false); StatusText("", false); StatusText("A safer alternative to running GameSrv as root is to run it via 'privbind'", false); StatusText("This will ensure GameSrv is able to bind to ports in the < 1024 range, but", false); StatusText("it will run as a regular unprivileged program in every other way", false); StatusText("", false); StatusText("See start.sh for an example of the recommended method to start GameSrv", false); StatusText("", false); } // Setup log handler RMLog.Handler += RMLog_Handler; // Init GameSrv _GameSrv = new GameSrv(); _GameSrv.Start(); // Main program loop bool Quit = false; while (!Quit) { char Ch = Crt.ReadKey(); switch (Ch.ToString().ToUpper()) { case "\0": char Ch2 = Crt.ReadKey(); if (Ch2 == ';') // F1 { StatusText("", false); StatusText("GameSrv WFC Screen Help", false); StatusText("-=-=-=-=-=-=-=-=-=-=-=-", false); StatusText("F1 = Help (this screen)", false); StatusText("C = Clear (clear the status window)", false); StatusText("P = Pause (reject new connections, leave existing connections alone)", false); StatusText("S = Setup (launch the config program)", false); StatusText("Q = Quit (shut down and terminate existing connections)", false); StatusText("", false); } break; case "C": Crt.ClrScr(); break; case "P": _GameSrv.Pause(); break; case "S": Process.Start(StringUtils.PathCombine(ProcessUtils.StartupPath, "GameSrvConfig.exe")); break; case "Q": // Check if we're already stopped (or are stopping) if ((_GameSrv.Status != GameSrvStatus.Stopped) && (_GameSrv.Status != GameSrvStatus.Stopping)) { int ConnectionCount = NodeManager.ConnectionCount; if (ConnectionCount > 0) { StatusText("", false); StatusText("There are " + ConnectionCount.ToString() + " active connections.", false); StatusText("Are you sure you want to quit [y/N]: ", false); Ch = Crt.ReadKey(); if (Ch.ToString().ToUpper() != "Y") { StatusText("", false); StatusText("Cancelling quit request.", false); StatusText("", false); continue; } } } _GameSrv.Stop(); _GameSrv.Dispose(); Quit = true; break; } } Environment.Exit(0); }