loadplayer() { char c; register loadL, loadR, ready, load; if (!mc->crew3) { Signal("Out of crew", (struct ship *)0); return; } loadL = mf->loadL; loadR = mf->loadR; if (!loadL && !loadR) { c = sgetch("Load which broadside (left or right)? ", (struct ship *)0, 1); if (c == 'r') loadL = 1; else loadR = 1; } if (!loadL && loadR || loadL && !loadR) { c = sgetch("Reload with (round, double, chain, grape)? ", (struct ship *)0, 1); switch (c) { case 'r': load = L_ROUND; ready = 0; break; case 'd': load = L_DOUBLE; ready = R_DOUBLE; break; case 'c': load = L_CHAIN; ready = 0; break; case 'g': load = L_GRAPE; ready = 0; break; default: Signal("Broadside not loaded.", (struct ship *)0); return; } if (!loadR) { mf->loadR = load; mf->readyR = ready|R_LOADING; } else { mf->loadL = load; mf->readyL = ready|R_LOADING; } loaded = 1; } }
void acceptboard(void) { struct ship *sp; int n; int crew[3]; int men = 0; char c; crew[0] = mc->crew1; crew[1] = mc->crew2; crew[2] = mc->crew3; for (n = 0; n < NBP; n++) { if (mf->OBP[n].turnsent) men += mf->OBP[n].mensent; } for (n = 0; n < NBP; n++) { if (mf->DBP[n].turnsent) men += mf->DBP[n].mensent; } if (men) { crew[0] = men/100 ? 0 : crew[0] != 0; crew[1] = (men%100)/10 ? 0 : crew[1] != 0; crew[2] = men%10 ? 0 : crew[2] != 0; } else { crew[0] = crew[0] != 0; crew[1] = crew[1] != 0; crew[2] = crew[2] != 0; } foreachship(sp) { if (sp == ms || sp->file->dir == 0 || range(ms, sp) > 1) continue; if (ms->nationality == capship(sp)->nationality) continue; if (meleeing(ms, sp) && crew[2]) { c = sgetch("How many more to board the %s (%c%c)? ", sp, 1); parties(crew, sp, 0, c); } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { c = sgetch("Crew sections to board the %s (%c%c) (3 max) ?", sp, 1); parties(crew, sp, 0, c); } } if (crew[2]) { c = sgetch("How many sections to repel boarders? ", NULL, 1); parties(crew, ms, 1, c); } blockalarm(); draw_slot(); unblockalarm(); }
play() { register struct ship *sp; for (;;) { switch (sgetch("~\b", (struct ship *)0, 0)) { case 'm': acceptmove(); break; case 's': acceptsignal(); break; case 'g': grapungrap(); break; case 'u': unfoulplayer(); break; case 'v': Signal("%s", (struct ship *)0, version); break; case 'b': acceptboard(); break; case 'f': acceptcombat(); break; case 'l': loadplayer(); break; case 'c': changesail(); break; case 'r': repair(); break; case 'B': Signal("'Hands to stations!'", (struct ship *)0); unboard(ms, ms, 1); /* cancel DBP's */ unboard(ms, ms, 0); /* cancel offense */ break; case '\f': centerview(); blockalarm(); draw_board(); draw_screen(); unblockalarm(); break; case 'L': mf->loadL = L_EMPTY; mf->loadR = L_EMPTY; mf->readyL = R_EMPTY; mf->readyR = R_EMPTY; Signal("Broadsides unloaded", (struct ship *)0); break; case 'q': Signal("Type 'Q' to quit", (struct ship *)0); break; case 'Q': leave(LEAVE_QUIT); break; case 'I': foreachship(sp) if (sp != ms) eyeball(sp); break; case 'i': if ((sp = closestenemy(ms, 0, 1)) == 0) Signal("No more ships left."); else eyeball(sp); break; case 'C': centerview(); blockalarm(); draw_view(); unblockalarm(); break; case 'U': upview(); blockalarm(); draw_view(); unblockalarm(); break; case 'D': case 'N': downview(); blockalarm(); draw_view(); unblockalarm(); break; case 'H': leftview(); blockalarm(); draw_view(); unblockalarm(); break; case 'J': rightview(); blockalarm(); draw_view(); unblockalarm(); break; case 'F': lookout(); break; case 'S': dont_adjust = !dont_adjust; blockalarm(); draw_turn(); unblockalarm(); break; } } }
repair() { char c; register char *repairs; register struct shipspecs *ptr = mc; register int count; #define FIX(x, m) (m - ptr->x > count \ ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m)) if (repaired || loaded || fired || changed || turned()) { Signal("No hands free to repair", (struct ship *)0); return; } c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1); switch (c) { case 'h': repairs = &mf->RH; break; case 'g': repairs = &mf->RG; break; case 'r': repairs = &mf->RR; break; default: Signal("Avast heaving!", (struct ship *)0); return; } if (++*repairs >= 3) { count = 2; switch (c) { case 'h': { int max = ptr->guns/4; if (ptr->hull < max) { FIX(hull, max); Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0); } break; } case 'g': if (ptr->gunL < ptr->gunR) { int max = ptr->guns/5 - ptr->carL; if (ptr->gunL < max) { FIX(gunL, max); Write(W_GUNL, ms, 0, ptr->gunL, ptr->carL, 0, 0); } } else { int max = ptr->guns/5 - ptr->carR; if (ptr->gunR < max) { FIX(gunR, max); Write(W_GUNR, ms, 0, ptr->gunR, ptr->carR, 0, 0); } } break; case 'r': #define X 2 if (ptr->rig4 >= 0 && ptr->rig4 < X) { FIX(rig4, X); Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0); } if (count && ptr->rig3 < X) { FIX(rig3, X); Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0); } if (count && ptr->rig2 < X) { FIX(rig2, X); Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0); } if (count && ptr->rig1 < X) { FIX(rig1, X); Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0); } break; } if (count == 2) { Signal("Repairs completed.", (struct ship *)0); *repairs = 2; } else { *repairs = 0; blockalarm(); draw_stat(); unblockalarm(); } } blockalarm(); draw_slot(); unblockalarm(); repaired = 1; }