Home  >  Article  >  Backend Development  >  “抢座位”的逻辑问题:如何获得可帮和可拆的部分

“抢座位”的逻辑问题:如何获得可帮和可拆的部分

WBOY
WBOYOriginal
2016-06-06 20:29:311291browse

$seat_parts = array('凳腿', '凳腿', '凳腿', '凳腿', '椅背', '扶手', '扶手');

数据库中

seat_build 记录用户椅子的进度
    user_id        total_step(完成椅子需要的步数)         done_step(已经完成的步数/部分)

seat_build_record 表用来记录相关的帮和拆记录
    user_id        to_user_id(关联seat_build中的user_id)    part_id(对应$seat_parts中的索引)    type(-1表示拆 1表示帮忙)

规则:

座椅完成以后就不能在拆了
拆的部分职能是在已经完成的部分中选

问题:

对于seat_build中的某个用户来说,如何快速的获得帮和拆的相应的座椅部分的索引?思路或者具体的代码均可

回复内容:

$seat_parts = array('凳腿', '凳腿', '凳腿', '凳腿', '椅背', '扶手', '扶手');

数据库中

seat_build 记录用户椅子的进度
    user_id        total_step(完成椅子需要的步数)         done_step(已经完成的步数/部分)

seat_build_record 表用来记录相关的帮和拆记录
    user_id        to_user_id(关联seat_build中的user_id)    part_id(对应$seat_parts中的索引)    type(-1表示拆 1表示帮忙)

规则:

座椅完成以后就不能在拆了
拆的部分职能是在已经完成的部分中选

问题:

对于seat_build中的某个用户来说,如何快速的获得帮和拆的相应的座椅部分的索引?思路或者具体的代码均可
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn