/* * Routine to print word corresponding to object */ public static string probj(State globals) { int wtype, wval; wtype = wval = 0; Tuple <bool, string> analysisResult = English.analyze(globals.word1, ref wtype, ref wval); return(analysisResult.Item2 + Environment.NewLine + (wtype == 1 ? globals.word1 : globals.word2)); }
/* * SAY etc. */ public static string vsay(State globals) { int wtype, wval; wtype = wval = 0; Tuple <bool, string> analysisResults = English.analyze(globals.word1, ref wtype, ref wval); return(analysisResults.Item2 + $"Okay.\n{(wval == Definitions.SAY ? globals.word2 : globals.word1)}\n"); }
/* * Routine to indicate no reasonable * object for verb found. Used mostly by * intransitive verbs. */ public static string needobj(State globals) { int wtype, wval; wtype = wval = 0; Tuple <bool, string> analysisResult = English.analyze(globals.word1, ref wtype, ref wval); return(analysisResult.Item2 + string.Format($"{(wtype == 2 ? globals.word1 : globals.word2)} what?\n")); }
/* * Routine to take 1 turn */ public static string turn(State globals, string nextLine) { string output = string.Empty; if (globals.IfFirstRun) { /* * if globals.closing, then he can't leave except via * the main office. */ if (globals.newloc < 9 && globals.newloc != 0 && globals.closing) { output += Database.rspeak(130); globals.newloc = globals.loc; if (globals.panic != 0) { globals.clock2 = 15; } globals.panic = 1; } /* * see if a Definitions.DWARF has seen him and has come * from where he wants to go. */ if (globals.newloc != globals.loc && !Database.forced(globals, globals.loc) && (globals.cond[globals.loc] & Definitions.NOPIRAT) == 0) { for (int i = 1; i < (Definitions.DWARFMAX - 1); ++i) { if (globals.odloc[i] == globals.newloc && globals.dseen[i]) { globals.newloc = globals.loc; output += Database.rspeak(2); break; } } } output += dwarves(globals); /* & special Definitions.DWARF(pirate who steals) */ /* added by BDS C conversion */ if (globals.loc != globals.newloc) { ++globals.turns; globals.loc = globals.newloc; /* causes occasional "move" with two describe & descitem */ /* } */ /* if (loc != globals.newloc) */ /* check for death */ if (globals.loc == 0) { output += death(globals); return(output); } /* check for forced move */ if (Database.forced(globals, globals.loc)) { output += describe(globals); output += domove(globals); return(output); } /* check for wandering in dark */ if (globals.wzdark && Database.dark(globals) && Database.pct(35)) { output += Database.rspeak(23); globals.oldloc2 = globals.loc; output += death(globals); return(output); } /* describe his situation */ output += describe(globals); if (!Database.dark(globals)) { ++globals.visited[globals.loc]; output += descitem(globals); } /* causes occasional "move" with no describe & descitem */ } /* if (loc != globals.newloc) */ if (globals.closed) { if (globals.prop[Definitions.OYSTER] < 0 && Database.toting(globals, Definitions.OYSTER)) { output += Database.pspeak(Definitions.OYSTER, 1); } for (int i = 1; i <= Definitions.MAXOBJ; ++i) { if (Database.toting(globals, i) && globals.prop[i] < 0) { globals.prop[i] = -1 - globals.prop[i]; } } } globals.wzdark = Database.dark(globals); if (globals.knfloc > 0 && globals.knfloc != globals.loc) { globals.knfloc = 0; } Tuple <bool, string> timerResult = stimer(globals); output += timerResult.Item2; if (timerResult.Item1) /* as the grains of sand slip by */ { return(output); } globals.IfFirstRun = false; } if (nextLine.Contains("exit") || nextLine.Contains("quit")) { globals.IfFirstRun = true; globals.Initialized = false; return("Restarting. Please enter a message to continue."); } Tuple <bool, string> lastParsedInstruction = English.english(globals, nextLine); /* retrieve player instructions */ globals.LastLineSuccessful = lastParsedInstruction.Item1; if (globals.LastLineSuccessful) { if ((globals.motion != 0)) /* execute player instructions */ { output += domove(globals); } else if (globals.@object != 0) { output += doobj(globals); } else { output += Verb.itverb(globals); } /* * if globals.closing, then he can't leave except via * the main office. */ if (globals.newloc < 9 && globals.newloc != 0 && globals.closing) { output += Database.rspeak(130); globals.newloc = globals.loc; if (globals.panic != 0) { globals.clock2 = 15; } globals.panic = 1; } /* * see if a Definitions.DWARF has seen him and has come * from where he wants to go. */ if (globals.newloc != globals.loc && !Database.forced(globals, globals.loc) && (globals.cond[globals.loc] & Definitions.NOPIRAT) == 0) { for (int i = 1; i < (Definitions.DWARFMAX - 1); ++i) { if (globals.odloc[i] == globals.newloc && globals.dseen[i]) { globals.newloc = globals.loc; output += Database.rspeak(2); break; } } } output += dwarves(globals); /* & special Definitions.DWARF(pirate who steals) */ /* added by BDS C conversion */ if (globals.loc != globals.newloc) { ++globals.turns; globals.loc = globals.newloc; /* causes occasional "move" with two describe & descitem */ /* } */ /* if (loc != globals.newloc) */ /* check for death */ if (globals.loc == 0) { output += death(globals); return(output); } /* check for forced move */ if (Database.forced(globals, globals.loc)) { output += describe(globals); output += domove(globals); return(output); } /* check for wandering in dark */ if (globals.wzdark && Database.dark(globals) && Database.pct(35)) { output += Database.rspeak(23); globals.oldloc2 = globals.loc; output += death(globals); return(output); } /* describe his situation */ output += describe(globals); if (!Database.dark(globals)) { ++globals.visited[globals.loc]; output += descitem(globals); } /* causes occasional "move" with no describe & descitem */ } /* if (loc != globals.newloc) */ if (globals.closed) { if (globals.prop[Definitions.OYSTER] < 0 && Database.toting(globals, Definitions.OYSTER)) { output += Database.pspeak(Definitions.OYSTER, 1); } for (int i = 1; i <= Definitions.MAXOBJ; ++i) { if (Database.toting(globals, i) && globals.prop[i] < 0) { globals.prop[i] = -1 - globals.prop[i]; } } } globals.wzdark = Database.dark(globals); if (globals.knfloc > 0 && globals.knfloc != globals.loc) { globals.knfloc = 0; } Tuple <bool, string> timerResult = stimer(globals); output += timerResult.Item2; if (timerResult.Item1) /* as the grains of sand slip by */ { return(output); } } return(output); }