GameLogAction.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class GameLogAction extends CommonAction
  10. {
  11. public function index()
  12. {
  13. $map = array();
  14. if ($_REQUEST['podcast_id']) {
  15. $map['podcast_id'] = intval($_REQUEST['podcast_id']);
  16. }
  17. if ($_REQUEST['game_id']) {
  18. $map['game_id'] = intval($_REQUEST['game_id']);
  19. }
  20. $name = $this->getActionName();
  21. $model = D($name);
  22. if (!empty($model)) {
  23. $this->_list($model, $map);
  24. }
  25. $games = M('games')->findAll();
  26. $this->assign ( 'url_name', get_manage_url_name());
  27. $this->assign("games", $games);
  28. $this->display();
  29. }
  30. public function edit()
  31. {
  32. $id = intval($_REQUEST['id']);
  33. $vo = M(MODULE_NAME)->where(array('id' => $id))->find();
  34. $game_id = $vo['game_id'];
  35. if ($game_id == 4) {
  36. $cards = [['type' => $vo['suit_patterns']]];
  37. } else {
  38. $game_type = array(
  39. 1 => array(
  40. '豹子',
  41. '同花顺',
  42. '同花',
  43. '顺子',
  44. '对子',
  45. '单牌',
  46. ),
  47. 2 => array(
  48. '五小',
  49. '炸弹',
  50. '五花',
  51. '四花',
  52. '牛牛',
  53. '牛九',
  54. '牛八',
  55. '牛七',
  56. '牛六',
  57. '牛五',
  58. '牛四',
  59. '牛三',
  60. '牛二',
  61. '牛一',
  62. '没牛',
  63. ),
  64. );
  65. $color = array('spade', 'heart', 'club', 'diamond');
  66. $cards = json_decode($vo['suit_patterns'], 1);
  67. foreach ($cards as $key => $value) {
  68. $img = '';
  69. foreach ($value['cards'] as $v) {
  70. $img .= '<img src="/admin/Tpl/default/Common/img/' . $color[$v[0]] . str_pad($v[1], 2, '0', 0) . '.gif" />';
  71. }
  72. $cards[$key]['img'] = $img;
  73. unset($cards[$key]['cards']);
  74. $cards[$key]['type'] = $game_type[$game_id][$value['type']];
  75. }
  76. }
  77. $this->assign('cards', $cards);
  78. $this->assign('vo', $vo);
  79. $this->display();
  80. }
  81. }