Compare View

switch
from
...
to
 
Commits (12)
src/GlobalVar.lua
... ... @@ -375,6 +375,7 @@ MailId = {
375 375  
376 376 RechargeBack = 3001,
377 377 DrawCode = 3002,
  378 + ActRadoTaskReward = 3003,
378 379 }
379 380  
380 381 TriggerEventType = {
... ...
src/ProtocolCode.lua
... ... @@ -270,6 +270,12 @@ actionCodes = {
270 270 Activity_actNewUserTaskRpc = 674,
271 271 Activity_buyBattleTicketRpc = 675,
272 272 Activity_resetGachakonRpc = 676, --狩猎祭,重制扭蛋机
  273 + Activity_startRegularWorldBossBattleRpc = 677,
  274 + Activity_endRegularWorldBossBattleRpc = 678,
  275 + Activity_regularWorldBossRewardRpc = 679,
  276 + Activity_buyWorldBossBattleTicketRpc = 680,
  277 + Activity_regularWorldBossMilestoneRpc = 681,
  278 +
273 279  
274 280 Radio_startQuestRpc = 700,
275 281 Radio_finishQuestRpc = 701,
... ...
src/RedisKeys.lua
... ... @@ -22,6 +22,7 @@ RANK_COMMON = "rank:common:"
22 22 RANK_TYPE = {
23 23 ActBattleBoss = "act_battle_boss",
24 24 ActCrisis = "crisis",
  25 + RegularWorldBoos = "regular_world_boss"
25 26 }
26 27  
27 28 -- rank
... ...
src/actions/ActivityAction.lua
... ... @@ -918,6 +918,7 @@ function _M.battleRankRpc(agent, data)
918 918 local actTypeToRank = {
919 919 [role.activity.ActivityType.ChallengeLevel] = RANK_TYPE.ActBattleBoss,
920 920 [role.activity.ActivityType.Crisis] = RANK_TYPE.ActCrisis,
  921 + [role.activity.ActivityType.RegularWorldBoos] = RANK_TYPE.RegularWorldBoos,
921 922 }
922 923 if not actTypeToRank[cfg.showType] then return end
923 924 local rankInfo = role:getRankInfoCommon(actTypeToRank[cfg.showType])
... ... @@ -1186,7 +1187,7 @@ function _M.friendHelpRpc(agent, data)
1186 1187 cmd1 = 2
1187 1188 end
1188 1189  
1189   - if members[friendId] and not getAE[friendId] and limit <= getLimit then
  1190 + if members[friendId] and not getAE[friendId] and limit < getLimit then
1190 1191 cmd2 = 1
1191 1192 limit = limit + 1
1192 1193 getAE[friendId] = 1
... ... @@ -1541,4 +1542,457 @@ function _M.buyBattleTicketRpc(agent, data)
1541 1542 return true
1542 1543 end
1543 1544  
  1545 +
  1546 +-- 常规世界boss
  1547 +function _M.startRegularWorldBossBattleRpc(agent, data)
  1548 + local role = agent.role
  1549 + local msg = MsgPack.unpack(data)
  1550 + local actid = msg.actid
  1551 + local id = msg.id
  1552 + local count = msg.count
  1553 +
  1554 + local actCfg = csvdb["activity_battleCsv"][actid]
  1555 + if not actCfg then return 2 end
  1556 +
  1557 + local battleCfg = actCfg[id]
  1558 + if not battleCfg then return 3 end
  1559 +
  1560 + local actData = role.activity:getActData("RegularWorldBoos") or {}
  1561 +
  1562 + local preArr = battleCfg.prepose:toArray(true, "=")
  1563 + for _, v in ipairs(preArr) do
  1564 + local battleInfo = actData[v]
  1565 + if not battleInfo then
  1566 + return 4
  1567 + end
  1568 + local star = battleInfo["star"] or 0
  1569 + if star <= 0 then
  1570 + return 4
  1571 + end
  1572 + end
  1573 + -- check cost
  1574 + local changeFlag = false
  1575 + local ticket = actData["ticket"]
  1576 + local num = 0 -- cost num
  1577 + if battleCfg.type ~= "" then
  1578 + role.activity:getRegularWorldBossTicket(actid)
  1579 + num = battleCfg.type:toArray(true, "=")[3]
  1580 + if count and count > 0 then
  1581 + if battleCfg.rank ~= 0 then
  1582 + local bi = actData[id]
  1583 + if not bi then return 8 end
  1584 + local star = bi["star"] or 0
  1585 + local maxP = bi["maxP"] or 0
  1586 + -- 世界boss
  1587 + if battleCfg.worldBoss_award ~= 0 then
  1588 + if maxP < 1 then
  1589 + return 9
  1590 + end
  1591 + else
  1592 + if star < 1 then
  1593 + return 9
  1594 + end
  1595 + end
  1596 + end
  1597 + num = num * count
  1598 + else
  1599 + num = 0
  1600 + end
  1601 + if ticket < num then
  1602 + return 6
  1603 + end
  1604 + changeFlag = true
  1605 + end
  1606 + -- 解锁活动剧情
  1607 + role:checkStoryStatus(false, 5, id)
  1608 +
  1609 + if not count then
  1610 + role.__regularWorldBossBattleCache = {
  1611 + key = tostring(math.random()),
  1612 + actid = actid,
  1613 + id = id,
  1614 + format = msg.format,
  1615 + }
  1616 + SendPacket(actionCodes.Activity_startRegularWorldBossBattleRpc, MsgPack.pack({key = role.__regularWorldBossBattleCache.key}))
  1617 + else
  1618 + if count <= 0 then
  1619 + return
  1620 + end
  1621 +
  1622 + local bi = actData[id]
  1623 + local star = bi["star"] or 0
  1624 + local award = battleCfg.item_clear:toNumMap()
  1625 +
  1626 + if battleCfg.rank ~= 0 then
  1627 + if getStarCount(battleCfg, star) == 3 then
  1628 + local aw = battleCfg.perfect_reward:toNumMap()
  1629 + for k, v in pairs(aw) do
  1630 + award[k] = (award[k] or 0) + v
  1631 + end
  1632 + end
  1633 + end
  1634 + for k, v in pairs(award) do
  1635 + award[k] = v * count
  1636 + end
  1637 + local reward, change = role:award(award, {log = {desc = "regularWorldBossBattle", int1 = actid, int2 = count or 0}})
  1638 +
  1639 + changeFlag = true
  1640 + actData["ticket"] = ticket - num
  1641 +
  1642 + if battleCfg.rank ~= 0 then
  1643 + if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then
  1644 + bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count
  1645 + end
  1646 +
  1647 + bi["sum"] = bi["sum"] + bi["top"] * count
  1648 + actData[id] = bi
  1649 +
  1650 + local rankVal = 0
  1651 + if battleCfg.rank == 1 then
  1652 + rankVal = bi["sum"]
  1653 + elseif battleCfg.rank == 2 then
  1654 + rankVal = bi["top"]
  1655 + end
  1656 + role:updateRankCommon(RANK_TYPE.RegularWorldBoos, rankVal)
  1657 + end
  1658 + role.activity:updateActData("RegularWorldBoos", actData)
  1659 +
  1660 + SendPacket(actionCodes.Activity_startRegularWorldBossBattleRpc, MsgPack.pack(role:packReward(reward, change)))
  1661 +
  1662 + return true
  1663 + end
  1664 +
  1665 + return true
  1666 +end
  1667 +
  1668 +function _M.endRegularWorldBossBattleRpc(agent, data)
  1669 + local role = agent.role
  1670 + local msg = MsgPack.unpack(data)
  1671 + local actid = msg.actid
  1672 + local id = msg.id
  1673 + local key = msg.key
  1674 + local isWin = msg.isWin
  1675 + local heros = msg.heros
  1676 + local support = msg.support
  1677 + if not role.activity:isOpenById(actid, "RegularWorldBoos") then
  1678 + SendPacket(actionCodes.Activity_endRegularWorldBossBattleRpc, MsgPack.pack({}))
  1679 + return true
  1680 + end
  1681 +
  1682 + if not role.__regularWorldBossBattleCache then return 2 end
  1683 +
  1684 + if role.__regularWorldBossBattleCache.id ~= id or role.__regularWorldBossBattleCache.key ~= key and role.__regularWorldBossBattleCache.actid ~= actid then
  1685 + SendPacket(actionCodes.Activity_endRegularWorldBossBattleRpc, MsgPack.pack({errorCode = 1}))
  1686 + end
  1687 +
  1688 + -- 防作弊
  1689 + if not role:checkBattleCheat("act_battle", {
  1690 + id = id,
  1691 + isWin = isWin,
  1692 + info = msg.info,
  1693 + format = role.__regularWorldBossBattleCache.format
  1694 + }) then
  1695 + SendPacket(actionCodes.Activity_endRegularWorldBossBattleRpc, MsgPack.pack({errorCode = 1}))
  1696 + return true
  1697 + end
  1698 + role.__regularWorldBossBattleCache = nil
  1699 +
  1700 + local actCfg = csvdb["activity_battleCsv"][actid]
  1701 + if not actCfg then return 3 end
  1702 +
  1703 + local battleCfg = actCfg[id]
  1704 + if not battleCfg then return 4 end
  1705 +
  1706 + local actData = role.activity:getActData("RegularWorldBoos") or {}
  1707 +
  1708 + -- 总输出
  1709 + local dmg = 0
  1710 + for k, v in pairs(msg.info.damage) do
  1711 + if k % 100 == 2 then
  1712 + dmg = dmg + v
  1713 + end
  1714 + end
  1715 +
  1716 + local reward, change = {}, nil
  1717 +
  1718 + local battleInfo = actData[id] or {}
  1719 + local curStar = 0
  1720 + if isWin then
  1721 + local herosInfo = msg.heros
  1722 +
  1723 + local check = {}
  1724 + -- 1 通关
  1725 + check[1] = function(_)
  1726 + return true
  1727 + end
  1728 + -- 2 阵亡人数 <= N
  1729 + check[2] = function(_, cond)
  1730 + return msg.info.dead and msg.info.dead <= cond
  1731 + end
  1732 + -- 3 全员存活
  1733 + check[3] = function(_)
  1734 + return msg.info.dead and msg.info.dead == 0
  1735 + end
  1736 + -- 4 指定种族 >= N
  1737 + check[4] = function(_, cond)
  1738 + local count = 0
  1739 + for _, one in pairs(herosInfo) do
  1740 + local heroData = csvdb["unitCsv"][one.type]
  1741 + if heroData.camp == cond then
  1742 + count = count + 1
  1743 + end
  1744 + end
  1745 + return count >= cond
  1746 + end
  1747 + -- 5 指定职业 >= N
  1748 + check[5] = function(_, cond)
  1749 + local count = 0
  1750 + for _, one in pairs(herosInfo) do
  1751 + local heroData = csvdb["unitCsv"][one.type]
  1752 + if heroData.job == cond then
  1753 + count = count + 1
  1754 + end
  1755 + end
  1756 + return count >= cond
  1757 + end
  1758 + -- 6 含有指定角色
  1759 + check[6] = function(_, cond)
  1760 + for _, one in pairs(herosInfo) do
  1761 + if one.type == cond then
  1762 + return true
  1763 + end
  1764 + end
  1765 + return false
  1766 + end
  1767 + -- 7 通关耗时 <= X 秒 msg.info.atime
  1768 + check[7] = function(_, cond)
  1769 + return msg.info.atime and msg.info.atime <= cond
  1770 + end
  1771 + -- 8 总输出值 msg.info.atime
  1772 + check[8] = function(_, cond)
  1773 + return dmg >= cond
  1774 + end
  1775 + curStar = 0
  1776 + local sweepConds = battleCfg.sweep_condition:toTableArray(true)
  1777 + for i, cond in ipairs(sweepConds) do
  1778 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  1779 + curStar = curStar + (1 << (i - 1))
  1780 + end
  1781 + end
  1782 +
  1783 + role:checkTaskEnter("ActBattlePass", {chapterId = id})
  1784 + else
  1785 + curStar = 0
  1786 + if battleCfg.rank ~= 0 then
  1787 + curStar = 1
  1788 + end
  1789 + end
  1790 + local oldStarNum = getStarCount(battleCfg, battleInfo["star"] or 0)
  1791 + local newStarNum = getStarCount(battleCfg, curStar)
  1792 + if newStarNum > oldStarNum then
  1793 + battleInfo["star"] = curStar
  1794 + end
  1795 +
  1796 + if battleCfg.rank ~= 0 and isWin then
  1797 + if battleCfg.type ~= "" then
  1798 + -- 消耗门票
  1799 + role.activity:getRegularWorldBossTicket(actid)
  1800 + local num = battleCfg.type:toArray(true, "=")[3]
  1801 + actData["ticket"] = math.max(actData["ticket"] - num, 0)
  1802 + end
  1803 +
  1804 + -- 更新排行榜 最高伤害
  1805 + battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg)
  1806 + battleInfo["sum"] = (battleInfo["sum"] or 0) + dmg
  1807 + local rankVal = 0
  1808 + if battleCfg.rank == 1 then
  1809 + rankVal = battleInfo["sum"]
  1810 + elseif battleCfg.rank == 2 then
  1811 + rankVal = battleInfo["top"]
  1812 + end
  1813 + if rankVal > 0 then
  1814 + role:updateRankCommon(RANK_TYPE.RegularWorldBoos, rankVal)
  1815 + end
  1816 + end
  1817 +
  1818 + if (oldStarNum == 0 and newStarNum > 0) or battleCfg.rank ~= 0 then
  1819 + reward = battleCfg.item_clear:toNumMap()
  1820 + end
  1821 + if (oldStarNum < 3 and newStarNum == 3) or (battleCfg.rank ~= 0 and newStarNum == 3) then
  1822 + local aw = battleCfg.perfect_reward:toNumMap()
  1823 + for k, v in pairs(aw) do
  1824 + reward[k] = (reward[k] or 0) + v
  1825 + end
  1826 + end
  1827 +
  1828 + role:checkBattle("act_battle", {
  1829 + cfg = battleCfg,
  1830 + star = newStarNum,
  1831 + isWin = isWin,
  1832 + info = msg.info,
  1833 + reward = reward,
  1834 + heros = heros,
  1835 + supports = support,
  1836 + })
  1837 +
  1838 + -- 解锁活动剧情
  1839 + if newStarNum >= 3 then
  1840 + role:checkStoryStatus(false, 5, id)
  1841 + end
  1842 +
  1843 + if battleCfg.worldBoss_award ~= 0 and msg.point then
  1844 + battleInfo["bossP"] = (battleInfo["bossP"] or 0) + msg.point
  1845 + battleInfo["maxP"] = math.max(msg.point, (battleInfo["maxP"] or 0))
  1846 + end
  1847 + actData[id] = battleInfo
  1848 + role.activity:updateActData("RegularWorldBoos", actData)
  1849 +
  1850 + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}})
  1851 +
  1852 + SendPacket(actionCodes.Activity_endRegularWorldBossBattleRpc, MsgPack.pack({
  1853 + reward = reward,
  1854 + change = change
  1855 + }))
  1856 +
  1857 + return true
  1858 +end
  1859 +
  1860 +function _M.regularWorldBossRewardRpc(agent, data)
  1861 + local role = agent.role
  1862 + local msg = MsgPack.unpack(data)
  1863 + local actid = msg.actid
  1864 + local id = msg.id
  1865 + local index = msg.index
  1866 +
  1867 + if not role.activity:isOpenById(actid, "RegularWorldBoos") then return 1 end
  1868 +
  1869 + local actCfg = csvdb["activity_battleCsv"][actid]
  1870 + if not actCfg then return 2 end
  1871 +
  1872 + local battleCfg = actCfg[id]
  1873 + if not battleCfg then return 3 end
  1874 +
  1875 + if battleCfg.worldBoss_award == 0 then return 4 end
  1876 +
  1877 + actCfg = csvdb["activity_wordboss_awardCsv"][battleCfg.worldBoss_award]
  1878 + if not actCfg then return 5 end
  1879 + local awardCfg = actCfg[index]
  1880 + if not awardCfg then return 6 end
  1881 +
  1882 + local totalAwardCnt = #actCfg
  1883 + local preList = awardCfg.condition1:toArray(true, "=")
  1884 +
  1885 + local actData = role.activity:getActData("RegularWorldBoos") or {}
  1886 + local battleInfo = actData[id] or {}
  1887 + local bossPoint = battleInfo["bossP"] or 0
  1888 + if bossPoint < 1 then return 7 end
  1889 +
  1890 + local bossRecord = battleInfo["bossR"] or ""
  1891 + local r = string.char(string.getbit(bossRecord, index))
  1892 + if r == "1" then
  1893 + return 9
  1894 + end
  1895 + local ok = false
  1896 + if #preList == 0 then
  1897 + ok = true
  1898 + else
  1899 + for _, i in ipairs(preList) do
  1900 + local flag = string.char(string.getbit(bossRecord, i))
  1901 + if flag == "1" then
  1902 + ok = true
  1903 + break
  1904 + end
  1905 + end
  1906 + end
  1907 + if not ok then return 8 end
  1908 +
  1909 + battleInfo["bossR"] = string.setbit(bossRecord, index)
  1910 + local allFinish = true
  1911 + for i = 1, totalAwardCnt do
  1912 + if string.char(string.getbit(battleInfo["bossR"], i)) == "0" then
  1913 + allFinish = false
  1914 + break
  1915 + end
  1916 + end
  1917 + if allFinish then
  1918 + battleInfo["bossR"] = ""
  1919 + end
  1920 + battleInfo["bossP"] = bossPoint - 1
  1921 + actData[id] = battleInfo
  1922 + role.activity:updateActData("RegularWorldBoos", actData)
  1923 +
  1924 + local award = awardCfg.reward:toNumMap()
  1925 + local reward, change = role:award(award, {log = {desc = "regularWorldBossReward", int1 = actid, int2 = index}})
  1926 + SendPacket(actionCodes.Activity_regularWorldBossRewardRpc, MsgPack.pack(role:packReward(reward, change)))
  1927 + return true
  1928 +end
  1929 +
  1930 +function _M.buyWorldBossBattleTicketRpc(agent, data)
  1931 + local role = agent.role
  1932 + local msg = MsgPack.unpack(data)
  1933 + local actid = msg.actid
  1934 + local id = msg.id
  1935 + local count = msg.count
  1936 + if not role.activity:isOpenById(actid, "RegularWorldBoos") then return 1 end
  1937 + role.activity:getRegularWorldBossTicket(actid)
  1938 + local actData = role.activity:getActData("RegularWorldBoos") or {}
  1939 + local battleInfo = actData[id] or {}
  1940 + --["activity_scrofa_tickets"] = { 10, 20, 30, 40, 50, 100, 150, 200, 200, 200 }
  1941 + --TODO
  1942 + local limit = #(globalCsv.activity_scrofa_tickets)
  1943 + local curCount = actData["buyC"] or 0
  1944 + if count <= 0 or curCount + count > limit then
  1945 + return 2
  1946 + end
  1947 + local cost = globalCsv.activity_scrofa_tickets[curCount + 1]
  1948 + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end
  1949 + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyRegularWorldBossTicket", int1 = actid, int2 = count, long1 = curCount}})
  1950 + actData["ticket"] = (actData["ticket"] or 0) + 1
  1951 + actData["buyC"] = curCount + count
  1952 +
  1953 + role.activity:updateActData("RegularWorldBoos", actData)
  1954 + SendPacket(actionCodes.Activity_buyWorldBossBattleTicketRpc, "")
  1955 + return true
  1956 +end
  1957 +
  1958 +function _M.regularWorldBossMilestoneRpc(agent, data)
  1959 + local role = agent.role
  1960 + local msg = MsgPack.unpack(data)
  1961 + local actid = msg.actid
  1962 + local id = msg.id
  1963 + local index = msg.index
  1964 +
  1965 + if not role.activity:isOpenById(actid, "RegularWorldBoos") then return 1 end
  1966 +
  1967 + local actCfg = csvdb["activity_mileageCsv"][actid]
  1968 + if not actCfg then return 3 end
  1969 +
  1970 + local mileCfg = actCfg[index]
  1971 + if not mileCfg then return 4 end
  1972 +
  1973 + local actData = role.activity:getActData("RegularWorldBoos") or {}
  1974 + local battleInfo = actData[id] or {}
  1975 + local val = 0
  1976 + if mileCfg.type == 1 then
  1977 + val = battleInfo["sum"] or 0
  1978 + elseif mileCfg.type == 2 then
  1979 + val = battleInfo["top"] or 0
  1980 + end
  1981 +
  1982 + local record = battleInfo["r"] or ""
  1983 + local flag = string.char(string.getbit(record, index))
  1984 + if flag == "1" then return 5 end
  1985 + if mileCfg.condition > val then return 6 end
  1986 +
  1987 + battleInfo["r"] = string.setbit(record, index)
  1988 + actData[id] = battleInfo
  1989 + role.activity:updateActData("RegularWorldBoos", actData)
  1990 +
  1991 + local award = mileCfg.reward:toNumMap()
  1992 + local reward, change = role:award(award, {log = {desc = "regularWorldBossMilestone", int1 = actid, int2 = index}})
  1993 + SendPacket(actionCodes.Activity_regularWorldBossMilestoneRpc, MsgPack.pack(role:packReward(reward, change)))
  1994 +
  1995 + return true
  1996 +end
  1997 +
1544 1998 return _M
... ...
1   -Subproject commit 45264603ff07db4cd2eaf8822c17f453bf5f00de
  1 +Subproject commit bd0ab7120f5574d3a720dd1bbeb513fb67b6d21b
... ...
src/models/Activity.lua
... ... @@ -40,6 +40,8 @@ Activity.ActivityType = {
40 40  
41 41 BattleCommandTask = 38, -- 战令任务活动
42 42 NewUserTask = 41, -- 新用户任务
  43 + RegularWorldBoos = 42, -- 常规世界boos
  44 + RadioTask = 43, -- 活动电台任务
43 45 }
44 46  
45 47 local function checkActivityType(activityType)
... ... @@ -93,6 +95,7 @@ Activity.schema = {
93 95  
94 96 act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
95 97 act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
  98 + act42 = {"table", {}}, --
96 99  
97 100 reset20 = {"number", 1}, -- 重置扭蛋机
98 101 }
... ... @@ -123,6 +126,7 @@ function Activity:data()
123 126  
124 127 act34 = self:getProperty("act34"),
125 128 act36 = self:getProperty("act36"),
  129 + act42 = self:getProperty("act42"),
126 130  
127 131 reset20 = self:getProperty("reset20")
128 132 }
... ... @@ -836,6 +840,21 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = {
836 840 end,
837 841 }
838 842  
  843 +--RegularWorldBoos
  844 +activityFunc[Activity.ActivityType.RegularWorldBoos] = {
  845 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  846 + self:getRegularWorldBossTicket(actId)
  847 + end,
  848 + ["login"] = function(self, actType, actId)
  849 + self:getRegularWorldBossTicket(actId)
  850 + end,
  851 + ["crossDay"] = function(self, actType, notify)
  852 + local actData = self:getActData(actType)
  853 + actData["buyC"] = 0
  854 + self:updateActData(actType, actData, not notify)
  855 + end,
  856 +}
  857 +
839 858 function Activity:onLoginActivity(actId)
840 859 local actData = csvdb["activity_ctrlCsv"][actId]
841 860 if not actData then return end
... ... @@ -1056,6 +1075,45 @@ function Activity:getBattleTicket(actId)
1056 1075 end
1057 1076 end
1058 1077  
  1078 +--常规世界boss计算门票
  1079 +function Activity:getRegularWorldBossTicket(actId)
  1080 + local role = self.owner
  1081 + local createTs = role:getProperty("ctime")
  1082 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  1083 + if not actCfg then return 0 end
  1084 +
  1085 + local actStartTime = 0
  1086 + local openTimes = actCfg.time:toArray(false, "=")
  1087 + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  1088 + local actData = self:getActData("RegularWorldBoos") or {}
  1089 + local startTs = actData["ts"] or math.max(actStartTime, createTs)
  1090 + local timeNow = skynet.timex()
  1091 + local modify = false
  1092 + local arr = actCfg.condition2:toArray(true, "=")
  1093 +
  1094 + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000
  1095 +
  1096 + local count = actData["ticket"] or init
  1097 + if count >= limit then
  1098 + actData["ts"] = timeNow
  1099 + self:updateActData("RegularWorldBoos", actData)
  1100 + return
  1101 + end
  1102 + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0)
  1103 +
  1104 + local newCount= math.min(count + add, limit)
  1105 + if newCount ~= count or newCount >= limit then
  1106 + modify = true
  1107 + end
  1108 + add = newCount - count
  1109 +
  1110 + if modify or not next(actData) then
  1111 + actData["ticket"] = newCount
  1112 + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60)
  1113 + self:updateActData("RegularWorldBoos", actData)
  1114 + end
  1115 +end
  1116 +
1059 1117 activityFunc[Activity.ActivityType.ActShopGoods] = {
1060 1118 ["init"] = function(self, actType, isCrossDay, notify, actId)
1061 1119 end,
... ... @@ -1216,7 +1274,7 @@ activityFunc[Activity.ActivityType.BattleCommand] = {
1216 1274 actData["week"] = math.min(old + count, limit)
1217 1275 count = actData["week"] - old
1218 1276 end
1219   - local total = actData["sum"] + count
  1277 + local total = (actData["sum"] or 0) + count
1220 1278 local curLvl = actData["lvl"] or 0
1221 1279 if actCfg.condition == 1 then -- 代表sum需要转换为等级
1222 1280 local bpCfg = csvdb["activity_battlepass_rewardCsv"][actId]
... ... @@ -1353,4 +1411,95 @@ activityFunc[Activity.ActivityType.AdvLevel] = {
1353 1411 end,
1354 1412 }
1355 1413  
  1414 +-- 获取英雄大成功率
  1415 +local function getHeroCoef(hero, condition)
  1416 + -- 基础概率
  1417 + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20}
  1418 + local rare = hero:getRare()
  1419 + local result = 0
  1420 + for _, it in ipairs(condition:toTableArray(true)) do
  1421 + local type = it[1]
  1422 + local value = it[2]
  1423 + local add = it[3]
  1424 + if type == 1 then -- 种族加成
  1425 + if hero:getCamp() == value then
  1426 + result = result + add
  1427 + end
  1428 + elseif type == 2 then -- 定位加成
  1429 + if hero:getPosition() == value then
  1430 + result = result + add
  1431 + end
  1432 + end
  1433 + end
  1434 +
  1435 + return result + (rareMap[rare] or 0)
  1436 +end
  1437 +
  1438 +local function getActRadioTaskReward(role, id, task)
  1439 + local config = csvdb["crusadeCsv"][id]
  1440 + if not config then return 2 end
  1441 + local carbonData = csvdb["idle_battleCsv"][config.unlock]
  1442 + if not carbonData then return 3 end
  1443 + -- get heros
  1444 + local totalCoef = 0
  1445 + local exp = config.time / 60
  1446 + for _, heroId in ipairs(task.heros) do
  1447 + local hero = role.heros[heroId]
  1448 + if hero then
  1449 + totalCoef = totalCoef + getHeroCoef(hero, config.success)
  1450 + -- 增加英雄信赖
  1451 + hero:addHeroFaith(exp)
  1452 + end
  1453 + end
  1454 + -- send award
  1455 + local bigSuccess = false
  1456 + local result = math.randomInt(0, 100)
  1457 + if result < totalCoef then
  1458 + bigSuccess = true
  1459 + end
  1460 + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
  1461 + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
  1462 + local itemReward = config.item_clear_special:toNumMap()
  1463 + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
  1464 + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
  1465 + if bigSuccess then
  1466 + for key, value in pairs(itemReward) do
  1467 + itemReward[key] = math.ceil(1.5 * value)
  1468 + end
  1469 + end
  1470 +
  1471 + return itemReward
  1472 +end
  1473 +
  1474 +
  1475 +activityFunc[Activity.ActivityType.RadioTask] = {
  1476 + -- ["check"] = function(self, actType, notify) -- 检查
  1477 + -- end,
  1478 + ["init"] = function(self, actType, isCrossDay, notify)
  1479 + end,
  1480 + ["close"] = function(self, actType, notify, actid)
  1481 + local radioTask = self.owner:getProperty("radioTask")
  1482 + local result = {}
  1483 + for id, task in pairs(radioTask) do
  1484 + -- check id
  1485 + local config = csvdb["crusadeCsv"][id]
  1486 + if config then
  1487 + if config.actid == actid then
  1488 + radioTask[id] = nil
  1489 +
  1490 + if not task then return 4 end
  1491 + if skynet.timex() < task.time then return 5 end
  1492 +
  1493 + local reward = getActRadioTaskReward(self.owner, id, task)
  1494 + for k, v in pairs(reward) do
  1495 + result[k] = (result[k] or 0) + v
  1496 + end
  1497 + end
  1498 + end
  1499 + end
  1500 + self.owner:sendMail(MailId.ActRadoTaskReward, nil, result, nil)
  1501 + self.owner:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  1502 + end,
  1503 +}
  1504 +
1356 1505 return Activity
... ...
src/models/Diner.lua
... ... @@ -232,7 +232,7 @@ function Diner:calSellReward(sell, delta, dishData, isExpedite)
232 232 upValue[-1] = (upValue[-1] or 0) + collectAdd
233 233  
234 234 -- 电波塔加成
235   - local goldCount = self.owner:getBnousDiner(4,addReward[ItemId.Gold])
  235 + local goldCount = (self.owner:getBnousDiner(4,addReward[ItemId.Gold]/delta, true) + self.owner:getBnousByZero(4)) * delta
236 236  
237 237 for id, count in pairs(addReward) do
238 238 addReward[id] = math.floor(count * (1 + (upValue[id] or 0) / 100))
... ...
src/models/RoleLog.lua
... ... @@ -70,6 +70,11 @@ local ItemReason = {
70 70 buyDiamondCardReward = 154, --购买钻石额外赠送奖励
71 71 firstMonthCardReward = 155, --首次订阅月卡奖励
72 72 firstSMonthCardReward = 156, --首次订阅特刊奖励
  73 + regularWorldBossReward = 157, -- 常规世界boss
  74 + regularWorldBossMilestone = 158, -- 常规世界boss伤害里程碑
  75 + regularWorldBossBattle = 159, -- 常规世界boss战斗奖励
  76 +
  77 +
73 78  
74 79 advHang = 301, -- 拾荒挂机
75 80 hangBattle = 302, -- 挂机战斗
... ... @@ -115,6 +120,8 @@ local ItemReason = {
115 120 battleCommandTask = 1011, -- 将军令任务
116 121 newUserTask = 1012, -- 新玩家任务
117 122 buyActivityBattleTicket = 1013, -- 购买门票
  123 + buyRegularWorldBossTicket = 1014, -- 购买门票
  124 +
118 125  
119 126 -- 餐厅
120 127 greenHourse = 1101, -- 食材获得
... ...
src/models/RolePlugin.lua
... ... @@ -2873,15 +2873,32 @@ function RolePlugin.bind(Role)
2873 2873 return self.towerBnousActive
2874 2874 end
2875 2875  
  2876 + function Role:bonusMerged(bonus1, bonus2)
  2877 + bonus1 = bonus1 or {}
  2878 + bonus2 = bonus2 or {}
  2879 +
  2880 + local bonus = {}
  2881 + bonus[0] = (bonus1[0] or 0) + (bonus2[0] or 0)
  2882 + bonus[1] = (bonus1[1] or 0) + (bonus2[1] or 0)
  2883 + return bonus
  2884 + end
  2885 +
  2886 + --计算公式是 (原价+固有提升数)*(1+赞誉度增幅中的百分比+电波塔中的百分比)
  2887 + --详细做法是 原价 + (原价+固有提升数) * (赞誉度增幅中的百分比+电波塔中的百分比) + 固有提升数
2876 2888 function Role:getDeltaValue(result, value)
2877 2889 if not result then return 0 end
2878 2890 local delta = 0
2879   - if result[1] and value then
2880   - delta = math.floor(value * result[1] / 100)
2881   - end
2882 2891 if result[0] then
2883 2892 delta = delta + result[0]
2884 2893 end
  2894 +
  2895 + if result[1] and value then
  2896 + if delta == 0 then
  2897 + delta = delta * result[1] / 100
  2898 + else
  2899 + delta = (delta + value )* result[1] / 100
  2900 + end
  2901 + end
2885 2902 return delta
2886 2903 end
2887 2904  
... ... @@ -2894,32 +2911,49 @@ function RolePlugin.bind(Role)
2894 2911 local towerBnous = self:getTowerBnousActive()
2895 2912 local levelBnous = self:getLevelBnous()
2896 2913  
2897   - local towerValue = self:getDeltaValue(towerBnous[SystemBnousType.CrusadeTask], value)
2898   - local levelValue = self:getDeltaValue(levelBnous[SystemBnousType.CrusadeTask], value)
2899   - return levelValue + towerValue
  2914 + local bonus = self:bonusMerged(towerBnous[SystemBnousType.CrusadeTask], levelBnous[SystemBnousType.CrusadeTask])
  2915 + return self:getDeltaValue(bonus, value)
2900 2916 end
2901 2917  
2902   - function Role:getBnousDiner(type, value)
  2918 + function Role:getBnousDiner(type, value, flag)
2903 2919 local towerBnous = self:getTowerBnousActive()
2904 2920 local levelBnous = self:getLevelBnous()
2905 2921 type = type or 1
2906   - local result, levelReault
  2922 + local bonus
2907 2923 if type == 1 then
2908   - result = towerBnous[SystemBnousType.DinerGet]
2909   - levelReault = levelBnous[SystemBnousType.DinerGet]
  2924 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerGet], levelBnous[SystemBnousType.DinerGet])
2910 2925 elseif type == 2 then
2911   - result = towerBnous[SystemBnousType.DinerLimit]
2912   - levelReault = levelBnous[SystemBnousType.DinerLimit]
  2926 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerLimit], levelBnous[SystemBnousType.DinerLimit])
2913 2927 elseif type == 3 then
2914   - result = towerBnous[SystemBnousType.DinerSell]
2915   - levelReault = levelBnous[SystemBnousType.DinerSell]
  2928 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerSell], levelBnous[SystemBnousType.DinerSell])
2916 2929 elseif type == 4 then
2917   - result = towerBnous[SystemBnousType.DinerPrice]
2918   - levelReault = levelBnous[SystemBnousType.DinerPrice]
  2930 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerPrice], levelBnous[SystemBnousType.DinerPrice])
  2931 + end
  2932 + dump(bonus)
  2933 + if not flag then
  2934 + return self:getDeltaValue(bonus, value) + (bonus[0] or 0)
  2935 + else
  2936 + return self:getDeltaValue(bonus, value)
2919 2937 end
2920   - return self:getDeltaValue(result, value) + self:getDeltaValue(levelReault, value)
2921 2938 end
2922 2939  
  2940 + function Role:getBnousByZero(type)
  2941 + local towerBnous = self:getTowerBnousActive()
  2942 + local levelBnous = self:getLevelBnous()
  2943 + type = type or 1
  2944 + local bonus
  2945 + if type == 1 then
  2946 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerGet], levelBnous[SystemBnousType.DinerGet])
  2947 + elseif type == 2 then
  2948 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerLimit], levelBnous[SystemBnousType.DinerLimit])
  2949 + elseif type == 3 then
  2950 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerSell], levelBnous[SystemBnousType.DinerSell])
  2951 + elseif type == 4 then
  2952 + bonus = self:bonusMerged(towerBnous[SystemBnousType.DinerPrice], levelBnous[SystemBnousType.DinerPrice])
  2953 + end
  2954 + return (bonus[0] or 0)
  2955 + end
  2956 +
2923 2957 local function appendAdvBnous(dstBnous, srcBnous)
2924 2958 if not dstBnous and not srcBnous then return {} end
2925 2959 local result = clone(dstBnous or {})
... ...