src/hcode/btech/mech.stat.c

Go to the documentation of this file.
00001 /*
00002  * Author: Markus Stenberg <fingon@iki.fi>
00003  *
00004  *  Copyright (c) 1997 Markus Stenberg
00005  *  Copyright (c) 1998-2002 Thomas Wouters
00006  *  Copyright (c) 2000-2002 Cord Awtry
00007  *       All rights reserved
00008  *
00009  * Created: Tue Aug 12 19:06:48 1997 fingon
00010  * Last modified: Tue Aug 12 20:04:59 1997 fingon
00011  */
00012 
00013 /* Make statistics 'bout what we do.. whatever it is we _do_ */
00014 
00015 #define MECH_STAT_C
00016 #include "mech.stat.h"
00017 #include "db.h"
00018 #include "externs.h"
00019 
00020 stat_type rollstat;
00021 
00022 void init_stat()
00023 {
00024         /* This is not necessary -- globals are always initialized empty */
00025         /* bzero(&stat, sizeof(stat)); */
00026 }
00027 
00028 static int chances[11] = { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
00029 
00030 void do_show_stat(dbref player, dbref cause, int key, char *arg1, char *arg2)
00031 {
00032         int i;
00033         float f1, f2;
00034 
00035         if(!rollstat.totrolls) {
00036                 notify(player, "No rolls to show statistics for!");
00037                 return;
00038         }
00039         for(i = 0; i < 11; i++) {
00040                 if(i == 0) {
00041                         notify(player, "#   Rolls  Optimal% Present% Diff. in 1000");
00042                 }
00043                 f1 = (float) chances[i] * 100.0 / 36.0;
00044                 f2 = (float) rollstat.rolls[i] * 100.0 / rollstat.totrolls;
00045                 notify_printf(player, "%-3d %6d %8.3f %8.3f %.3f", i + 2,
00046                                           rollstat.rolls[i], f1, f2, 10.0 * f2 - 10.0 * f1);
00047         }
00048         notify_printf(player, "Total rolls: %d", rollstat.totrolls);
00049 }

Generated on Mon May 28 04:25:22 2007 for BattletechMUX by  doxygen 1.4.7