Skip to content

Instantly share code, notes, and snippets.

@kfly8
Last active August 29, 2015 14:03
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 kfly8/d2d23c435801551a278f to your computer and use it in GitHub Desktop.
Save kfly8/d2d23c435801551a278f to your computer and use it in GitHub Desktop.
yapc asia 2014 の応募トークの断片
-- ゲームの終了条件まで"対戦"を行う、"ゲームプログラミング"をPerlで書く。
-- Battle.pm / Battle::Timelime / Battle::Fighter
-- 定時対戦 -> lockを書けないで済むようにする/ 障碍検知、復旧のしやすいポリシー
CREATE TABLE battle_timeline (
..
timeline_msgpack BLOB NOT NULL COMMENT '対戦結果データ',
)
-- 「とりあえず、id いれよう」 から covering index
-- redisのfallbackの用意
-- LeaderBoard
CREATE TABLE xxx_ranking (
user_id INTEGER UNSIGNED NOT NULL,
xxx_id INTEGER UNSIGNED NOT NULL,
score INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (xxx_id, user_id),
INDEX (xxx_id, score)
)
# relation / id chain / BK
my %id2foo = map { $_->id => $_ } @{$db->search(+{ ... })};
my %id2bar = map { $_->id => $_ } @{$db->search(+{ id => [keys %id2foo] });
-- lock
CREATE TABLE user_status (
user_id INTEGER UNSIGNED NOT NULL,
action_pt INTEGER SIGNED NOT NULL COMMENT '行動力',
...
)
UPDATE action_pt = action_pt - 10
-- attr_type でのtable振りわけ / BK
CREATE TABLE xxx_incentive (
id
threshold
attr_type ENUM('aaa', 'bbb') NOT NULL,
attr_id INTEGER UNSIGNED NOT NULL
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment