예제 #1
0
파일: west.c 프로젝트: gongfuPanada/xyj45
int valid_leave (object who, string dir)
{
  if (wizardp(who))
    return ::valid_leave(who, dir);
  if (dir == "eastdown")
    //return notify_fail ("对不起,您不能擅自闯入赛场。\n");
    return can_enter (who);
  return ::valid_leave(who, dir);
}
예제 #2
0
파일: movement.cpp 프로젝트: ejrh/hex
bool MovementModel::check_step(const UnitStack& stack, StackMovePoints *points, const Path& path, int step_num) const {
    Point next_step = path[step_num];

    if (!can_enter(stack, next_step))
        return false;

    for (unsigned int i = 0; i < stack.units.size(); i++) {
        Unit& unit = *stack.units[i];
        int cost = cost_to(unit, next_step);
        points->points[i] -= cost;
    }

    return !points->exhausted();
}
예제 #3
0
파일: movement.cpp 프로젝트: ejrh/hex
int MovementModel::cost_to(const UnitStack& party, const Point& tile_pos) const {
    if (!can_enter(party, tile_pos))
        return INT_MAX;

    //TODO if one unit is a transport, then the others move for free

    int total_cost = 0;
    for (auto iter = party.units.begin(); iter != party.units.end(); iter++) {
        Unit& unit = **iter;
        int cost = cost_to(unit, tile_pos);
        if (cost == INT_MAX) {
            total_cost = INT_MAX;
            break;
        }
        total_cost += cost;
    }

    return total_cost;
}