Skip to content

Instantly share code, notes, and snippets.

@kuboon
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuboon/e5c779833e7b8dc405ed to your computer and use it in GitHub Desktop.
Save kuboon/e5c779833e7b8dc405ed to your computer and use it in GitHub Desktop.
人狼アリーナ API

POST /villages

村を建てます。

村の名前と説明を指定します。村の説明は、他のプレイヤーの参加を待つ間何度でも変更可能ですが、村の名前は後からは変更できません。

また、この村でのあなたの名前も指定してください。これも後からは変更できません。

Example

Request

POST /s/villages.json HTTP/1.1
Content-Type: application/json

{
  "village": {
    "name": "絶望の",
    "description": "xx部悪女決定戦!"
  },
  "you": {
    "name": "やまっちー"
  }
}

Response

HTTP/1.1 200
Content-Type: application/json; charset=utf-8

{
  "alerts": [
    {
      "info": "サインインしました。"
    }
  ],
  "csrf_param": "authenticity_token",
  "csrf_token": "UbxxvvzRyicDpIninnM72GfmUG6VQ5L/z+xrKMLSkj1aTKlbMmd7I+eHxvPXR1hds+qqmvLC+9IDkG/5/YJhoA==",
  "user": {
    "id": 3548,
    "username": "twitter_10000",
    "icon_url": null,
    "village_id": null,
    "created_at": "2015-07-29T03:34:49.756+09:00",
    "updated_at": "2015-07-29T03:34:49.756+09:00"
  },
  "village": {
    "id": 1216,
    "name": "絶望の",
    "description": "xx部悪女決定戦!",
    "token": "t58731",
    "options": {
    },
    "status": "regulation",
    "winner_side": null,
    "owner": true,
    "member": true,
    "creatures": {
      "6331": {
        "id": 6331,
        "name": "やまっちー",
        "die_of": null
      }
    },
    "days": [

    ]
  },
  "links": [
    {
      "rel": "self",
      "href": "http://example.org/s/villages/1216"
    },
    {
      "rel": "start",
      "method": "POST",
      "href": "http://example.org/s/villages/1216/start"
    }
  ]
}

POST /s/villages/:id/start

編成人数と参加人数が合っていれば、村を開始します。

time_limit_slope と time_limit_intersept で制限時間を指定出来ます。どちらも 0 にすると、ターン制 (全員がコミットすると翌日) となります。

  • time_limit_slope: 生存人数にこれを掛けたものが制限時間(分)になります
  • time_limit_intersept: 生存人数にこれを足したものが制限時間(分)になります

例えば、time_limit_slope: 1, time_limit_intersept: -2 とすると、 10人で8分、8人で6分と減っていき、最終日4人で2分となります。短期人狼に調度良い設定です。 time_limit_slope: 0, time_limit_intersept: 60 とすれば、生存人数によらず、1時間毎に日が変わります。

実際の1日と合わせた、標準的な長期人狼の設定にするには、 time_limit_slope: 0, time_limit_intersept: 1440 としてください。

小数も使用可能です。 1.5 は90秒を意味します。 制限時間が1分未満の場合は自動的に1分になります。

Example

Request

POST /s/villages/1217/start HTTP/1.1
Content-Type: application/json

{
  "village": {
    "description": "xx部悪女決定戦! LINE name で登録してね!!",
    "regulation": {
      "wolf": 1,
      "villager": 2,
      "bitch": 1
    },
    "options": {
      "time_limit_slope": 1,
      "time_limit_intersept": -2
    }
  }
}

Response

HTTP/1.1 200
Content-Type: application/json; charset=utf-8

{
  "alerts": [
    {
      "info": "サインインしました。"
    }
  ],
  "csrf_param": "authenticity_token",
  "csrf_token": "fdfcg2huJcwaQludY3XSI0ufPGD8WfRS8x8ssAo/uPmRvk7OuTVn0Z7/Vra/2fVxIzIHHwDwTPjqIe4Ap/O04w==",
  "user": {
    "id": 3549,
    "username": "twitter_10001",
    "icon_url": null,
    "village_id": null,
    "created_at": "2015-07-29T03:34:49.985+09:00",
    "updated_at": "2015-07-29T03:34:49.985+09:00"
  },
  "village": {
    "id": 1217,
    "name": "test village",
    "description": "xx部悪女決定戦! LINE name で登録してね!!",
    "token": null,
    "options": {
      "time_limit_slope": 1
    },
    "status": "regulation",
    "winner_side": null,
    "owner": true,
    "member": false,
    "days": [

    ]
  },
  "links": [
    {
      "rel": "self",
      "href": "http://example.org/s/villages/1217"
    },
    {
      "rel": "start",
      "method": "POST",
      "href": "http://example.org/s/villages/1217/start"
    }
  ]
}

PUT /s/villages/:id/days/:day

投票、占い、護衛、襲撃などのアクションの対象を指定します。対象を指定しないまま夜を迎えると、アクションは発動しません。 (投票は例外で、誰も投票しなくても必ず誰かが対象になります)

霊視は対象が決まっているので指定は不要で、(処刑者がいれば) 必ず発動します。

実際にアクションが実行されるのは夜になってからです。 制限時間を過ぎていたり、全員のコミットが揃って既に夜フェーズに入っている場合は 410 Gone が返ります。

Example

Request

PUT /s/villages/1218/days/1 HTTP/1.1
Content-Type: application/x-www-form-urlencoded

vote=6338

Response

HTTP/1.1 200
Content-Type: application/json; charset=utf-8

{
  "alerts": [
    {
      "info": "サインインしました。"
    }
  ],
  "csrf_param": "authenticity_token",
  "csrf_token": "Tyo/YGHXk+SZ90HS/vN02hHIc1yiT//tyH0DzNkyk3cq6Idr+/7Q1ttYQAwyEocYlyXfbvez6/WyDx6yElW1mQ==",
  "user": {
    "id": 3550,
    "username": "twitter_10002",
    "icon_url": null,
    "village_id": null,
    "created_at": "2015-07-29T03:34:50.062+09:00",
    "updated_at": "2015-07-29T03:34:50.062+09:00"
  },
  "village": {
    "id": 1218,
    "name": "test village",
    "description": null,
    "token": null,
    "options": {
    },
    "status": "playing",
    "winner_side": null,
    "owner": true,
    "member": true,
    "creatures": {
      "6344": {
        "id": 6344,
        "name": "教祖メイソン",
        "die_of": null
      },
      "6343": {
        "id": 6343,
        "name": "法律家リアム",
        "die_of": null
      },
      "6342": {
        "id": 6342,
        "name": "鍛冶屋ノア",
        "die_of": null
      },
      "6341": {
        "id": 6341,
        "name": "記者リリイ",
        "die_of": null
      },
      "6340": {
        "id": 6340,
        "name": "教師エミリー",
        "die_of": null
      },
      "6339": {
        "id": 6339,
        "name": "乳母シャーロット",
        "die_of": null
      },
      "6338": {
        "id": 6338,
        "name": "料理人アメリア",
        "die_of": null
      },
      "6337": {
        "id": 6337,
        "name": "絵描きハーパー",
        "die_of": null
      },
      "6336": {
        "id": 6336,
        "name": "司書アビゲイル",
        "die_of": null
      },
      "6335": {
        "id": 6335,
        "name": "旅芸人クロエ",
        "die_of": null
      },
      "6334": {
        "id": 6334,
        "name": "薬師オリビア",
        "die_of": null
      },
      "6333": {
        "id": 6333,
        "name": "仕立屋エマ",
        "die_of": null
      },
      "6332": {
        "id": 6332,
        "name": "花屋ソフィア",
        "die_of": null
      }
    },
    "days": [
      {
        "num": 0,
        "lynch_id": null,
        "victim_ids": [

        ],
        "commits_left": 13,
        "limit_at_unixtime": null,
        "notices": {
        },
        "is_today": false
      },
      {
        "num": 1,
        "lynch_id": null,
        "victim_ids": [

        ],
        "commits_left": 12,
        "limit_at_unixtime": null,
        "notices": {
        },
        "actions": {
          "6332": {
            "bite": null,
            "vote": null
          }
        },
        "is_today": true
      }
    ]
  },
  "messages": {
    "0": [
      [
        "regulation",
        "この村には、人狼が3人、狂人が1人、占い師が1人、霊能者が1人、狩人が1人、村人が6人いるようです。",
        "この村には、人狼が3人、狂人が1人、占い師が1人、霊能者が1人、狩人が1人、村人が6人いるようです。"
      ],
      [
        "you",
        "あなたは人狼です。",
        "<span class='you'>あなた</span>は人狼です。"
      ]
    ]
  },
  "you": {
    "id": 6332,
    "name": "花屋ソフィア",
    "die_of": null,
    "type": "wolf",
    "commit": true,
    "actions": {
      "vote": {
        "target_id": null,
        "candidates": [
          6344,
          6343,
          6342,
          6341,
          6340,
          6339,
          6338,
          6337,
          6336,
          6335,
          6334,
          6333
        ]
      },
      "bite": {
        "target_id": null,
        "candidates": [
          6344,
          6343,
          6342,
          6341,
          6340,
          6339,
          6338,
          6337,
          6336,
          6335
        ]
      }
    }
  },
  "links": [
    {
      "rel": "self",
      "href": "http://example.org/s/villages/1218"
    },
    {
      "rel": "action",
      "method": "PATCH",
      "href": "http://example.org/s/villages/1218/days/1"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment