ShelpAm / little-sb

0 stars 3 forks source link

bug #7

Open buouuuu opened 2 days ago

buouuuu commented 2 days ago

battle直接杀死对面

ShelpAm commented 2 days ago

经过排查,这个bug是因为命令传输违背了统一的接口,修正为如下

void Battle::stop(Stop_cause cause)
{
  switch (cause) {
  case Stop_cause::normal: {
    Event game_end{"game-end"};
    _session_service->push_event(_players[0]->name(), game_end);

    Event message{"message"};
    message.add_arg("Someone's health has dropped to 0."); // 修改后
    // message.add_arg(cause); // 此处之前为int (cause为int)
    _session_service->push_event(_players[1]->name(), message);
    break;
  }
  case Stop_cause::escaping: {
    Event message{"message"};
    message.add_arg("Your opponent has escaped from the battle.");
    _session_service->push_event(_players[1]->name(), message);
    break;
  }
  }

  _ended = true;
}

然而,更改后发出的消息不自然,需要再次修改。