1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include "handwave.h"
#include "internal.h"
#include <libintl.h>
#define _(String) gettext (String)
static char bigbuf[512];
void log_text();
void init_transcript(self)
struct realgame *self;
{
self->gamelog_size = 4096;
self->gamelog = (char *)malloc(sizeof(char) * self->gamelog_size);
strcpy(self->gamelog, "");
self->gamelog_pos = 0;
log_text(self, _("Spellcast Game Transcript\n\n"));
}
void log_text(self, str)
struct realgame *self;
char *str;
{
int len;
if (!str)
return;
len = strlen(str);
if (len+self->gamelog_pos >= self->gamelog_size) {
while (len+self->gamelog_pos >= self->gamelog_size) {
self->gamelog_size *= 2;
}
self->gamelog = (char *)realloc(self->gamelog, sizeof(char) * self->gamelog_size);
}
strcpy(self->gamelog+self->gamelog_pos, str);
self->gamelog_pos += len;
}
void LogInTranscript(pgame, str)
game *pgame;
char *str;
{
log_text((struct realgame *)pgame, str);
}
static char cheap_untranslate(val)
int val;
{
switch (val) {
case Gesture_PALM:
return 'P';
case Gesture_DIGIT:
return 'D';
case Gesture_FINGERS:
return 'F';
case Gesture_WAVE:
return 'W';
case Gesture_SNAP:
return 'S';
case Gesture_CLAPHALF:
return 'C';
case Gesture_KNIFE:
return 'K';
case Gesture_NOTHING:
return '.';
case Gesture_ANTISPELL:
return '=';
default:
return '?';
}
}
void log_round_header(self)
struct realgame *self;
{
char *cx;
int ix, gnum;
switch (self->turntype) {
case Turn_TIMESTOP:
cx = _(" (Time Stop)");
break;
case Turn_HASTE:
cx = _(" (Haste)");
break;
default:
cx = "";
break;
}
sprintf(bigbuf, _("\n\tTurn %d%s:\n"), self->turn, cx);
log_text(self, bigbuf);
for (ix=0; ix<self->numplayers; ix++) {
struct wizard *wiz = self->wiz[ix];
if (wiz->alive) {
if (self->turnactive[ix]) {
gnum = wiz->numgests-1;
sprintf(bigbuf, _("%s (%d): %c %c\n"), wiz->name, wiz->hitpoints,
cheap_untranslate(wiz->gests[gnum].did[0]),
cheap_untranslate(wiz->gests[gnum].did[1]));
}
else {
sprintf(bigbuf, _("%s (%d): [no gestures]\n"), wiz->name,
wiz->hitpoints);
}
log_text(self, bigbuf);
}
}
for (ix=0; ix<self->numcres; ix++) {
struct creature *thud = &(self->cre[ix]);
if (thud->alive) {
sprintf(bigbuf, _("%s (%d)\n"), thud->name, thud->hitpoints);
log_text(self, bigbuf);
}
}
log_text(self, _("\n"));
}
#define ABBREVLEN (8)
void WriteTranscript(pgame, f)
game *pgame;
FILE *f;
{
struct realgame *self = (struct realgame *)pgame;
fputs(self->gamelog, f);
}
|