Advertisement
Guest User

DAC chess drawing code

a guest
May 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | None | 0 0
  1. --游戏循环1.2——抽卡
  2. function PrepareARound(teamid)
  3.     Draw5ChessAndShow(teamid, false)
  4. end
  5. --游戏循环1.2.x——抽卡用到的方法(第二个参数可以指定下一个棋子)
  6. function Draw5ChessAndShow(team_id, unlock)
  7.     local h = TeamId2Hero(team_id)
  8.     if h.chesslock == true then
  9.         CustomGameEventManager:Send_ServerToTeam(h:GetTeam(),"show_draw_card",{
  10.             key = GetClientKey(h:GetTeam()),
  11.             cards = nil,
  12.             curr_money = h:GetMana(),
  13.             auto_unlock = true,
  14.         })
  15.         h.chesslock = false
  16.         return
  17.     end
  18.     --把上次剩的洗回棋库
  19.     h.ban_chess_list = {}
  20.     if h.curr_chess_table ~= nil then
  21.         for _,chess in pairs(h.curr_chess_table) do
  22.             if chess ~= nil then
  23.                 -- table.insert(h.ban_chess_list,chess)
  24.                 AddAChessToChessPool(chess)
  25.             end
  26.         end
  27.     end
  28.     h.curr_chess_table = {}
  29.     --抽!
  30.     local cards,curr_chess_table = RandomNDrawChessNew(team_id,5)
  31.     h.curr_chess_table = curr_chess_table
  32.  
  33.     CustomGameEventManager:Send_ServerToTeam(team_id,"show_draw_card",{
  34.         key = GetClientKey(team_id),
  35.         chesses = curr_chess_table,
  36.         cards = cards,
  37.         curr_money = h:GetMana(),
  38.         unlock = unlock,
  39.     })
  40. end
  41. function RandomNDrawChessNew(team_id,n)
  42.     local new_chess_list_str = ""
  43.     local new_chess_list_table = {}
  44.     local chess_count = 0
  45.        
  46.     while chess_count < n do
  47.         local new_chess = RandomDrawChessNew(team_id)
  48.         if new_chess ~= nil then
  49.             new_chess_list_str = new_chess_list_str..new_chess..','
  50.             -- table.insert(new_chess_list_table,new_chess)
  51.             chess_count = chess_count + 1
  52.             new_chess_list_table[chess_count] = new_chess
  53.         end
  54.     end
  55.     return new_chess_list_str,new_chess_list_table
  56. end
  57. function RandomDrawChessNew(team_id)
  58.     local h = TeamId2Hero(team_id)
  59.     local this_chess = nil
  60.     local ran = RandomInt(1,100)
  61.     local chess_level = 1
  62.     local curr_per = 0
  63.     local hero_level = h:GetLevel()
  64.  
  65.     local table_11chess = {}
  66.     for _,chess in pairs(GameRules:GetGameModeEntity().mychess[team_id]) do
  67.         if string.find(chess.chess,'11') then
  68.             table.insert(table_11chess,string.sub(chess.chess,1,-3))
  69.         end
  70.     end
  71.    
  72.     local ran1 = RandomInt(1,10000)
  73.     local ran2 = RandomInt(1,10000)
  74.     if h:GetLevel() >= 7 and ran1 <= 1 and ran2 <= 1 then
  75.         this_chess = GameRules:GetGameModeEntity().chess_list_ssr[RandomInt(1,table.maxn(GameRules:GetGameModeEntity().chess_list_ssr))]
  76.     elseif ran1 <= 30 then
  77.         this_chess = 'chess_io'
  78.     else
  79.         --正常抽牌
  80.         if GameRules:GetGameModeEntity().chess_gailv[hero_level] ~= nil then
  81.             for per,lv in pairs(GameRules:GetGameModeEntity().chess_gailv[hero_level]) do
  82.                 if ran>per and curr_per<=per then
  83.                     curr_per = per
  84.                     chess_level = lv
  85.                 end
  86.             end
  87.         end
  88.         -- this_chess = GameRules:GetGameModeEntity().chess_list_by_mana[chess_level][RandomInt(1,table.maxn(GameRules:GetGameModeEntity().chess_list_by_mana[chess_level]))]
  89.  
  90.         this_chess = DrawAChessFromChessPool(chess_level, table_11chess, h.ban_chess_list)
  91.     end
  92.     return this_chess
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement