COMMAND.H
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:3k
源码类别:

游戏

开发平台:

Visual C++

  1. // (C) Copyright 1996 by Anthony J. Carin.  All Rights Reserved.
  2. #ifndef COMMAND_H
  3. #define COMMAND_H
  4. #include <time.h>
  5. inline short random(short v)
  6. {
  7.     return (short)((rand()*v) / RAND_MAX);
  8. }
  9. enum insttype
  10. {
  11. ENDSESSION,
  12. INSERTFILE,
  13. THEYDO,
  14. TILTBODYRIGHT,
  15. TILTBODYLEFT,
  16. TILTBODYFWD,
  17. TILTBODYBCK,
  18. TURNHEADLEFT,
  19. TURNHEADRIGHT,
  20. TURNHEADUP,
  21. TURNHEADDOWN,
  22. RLEGBENDKNEE,
  23. LLEGBENDKNEE,
  24. RLEGRAISEFWD,
  25. LLEGRAISEFWD,
  26. RLEGRAISEBCK,
  27. LLEGRAISEBCK,
  28. RLEGRAISESIDE,
  29. LLEGRAISESIDE,
  30. RARMBENDELBOW,
  31. LARMBENDELBOW,
  32. RARMRAISEFWD,
  33. LARMRAISEFWD,
  34. RARMRAISEBCK,
  35. LARMRAISEBCK,
  36. RARMRAISESIDE,
  37. LARMRAISESIDE,
  38. TURNRIGHT,
  39. TURNLEFT,
  40. MOVEUPWARD,
  41. MOVEFOWARD,
  42. MOVEBACKWARD,
  43. PLAYSOUND,
  44. PLAYGENERIC,
  45. BEGINPROTECT,
  46. ENDPROTECT,
  47. STRIKETOP,
  48. STRIKEMED,
  49. STRIKEBOT,
  50. TILTRIGHTWEAPON,
  51. TILTLEFTWEAPON,
  52. CLEAR,
  53. HURTME,
  54. RTHROW,
  55. LTHROW,
  56. PICKUP,
  57. NOMORE,
  58. NOTEXIST
  59. };
  60. class instruction
  61. {
  62. public:
  63.          instruction();
  64.          instruction(instruction& i);
  65.         ~instruction()               { delete m_string; }
  66. insttype operator()()                { return m_inst; }
  67. float    value()                     { return m_value; }
  68. void     operator=(instruction& i);
  69. void     operator=(insttype v)       { m_inst = v; }
  70. char    *string()                    { return m_string; }
  71. void     setvalue(float v)           { m_value = v; }
  72. void     setstring(char *);
  73. instruction *Next;
  74. private:
  75. insttype m_inst;
  76. float    m_value;
  77. char    *m_string;
  78. };
  79. class instlist
  80. {
  81. public:
  82.             instlist()     { First = Last = Current = 0; m_purgeold = m_protected = FALSE; }
  83.            ~instlist()     { purge(); }
  84. void        add(instruction& i);
  85. instruction& next();
  86. void        restart()      { Current = First; }
  87. char        nomore()       { return (char)(Current == 0); }
  88. char        isempty()      { return (char)(First == 0); }
  89. void        purgeold()     { m_purgeold = TRUE; }
  90. void        purge();
  91. void        remove(insttype v);
  92. private:
  93. instruction *First;
  94. instruction *Last;
  95. instruction *Current;
  96. char        m_purgeold;
  97. char        m_protected;
  98. };
  99. class command
  100. {
  101. public:
  102.             command(LPCTSTR filename);
  103.            ~command()   { delete m_instlist; }
  104. instruction& next()     { return m_instlist->next(); }
  105. void        restart()   { m_instlist->restart(); }
  106. char        nomore()    { return m_instlist->nomore(); }
  107. void        purge()     { m_instlist->purge(); }
  108. void        purgeold()  { restart(); m_instlist->purgeold(); }
  109. void        append(command& c);
  110. void        remove(insttype v)  { m_instlist->remove(v); }
  111. void        add(instruction& i) { m_instlist->add(i); }
  112. char        isempty()   { return m_instlist->isempty(); }
  113. void        AddToValue(insttype instruct, short bonus);
  114. private:
  115. instlist   *m_instlist;
  116. };
  117. #endif