Skip to content

Commit

Permalink
fix: support vote mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed Apr 19, 2020
1 parent e38a13a commit 95e5b0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "champ-r",
"version": "0.9.3",
"version": "0.9.4",
"license": "MIT",
"description": "Get champion items for lol, Windows only.",
"productName": "ChampR",
Expand Down
14 changes: 9 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Settings from 'src/modules/settings';
import LCUService from 'src/service/lcu';

const engine = new Styletron();
const GameTypes = [`pick`];

const findUserChampion = (cellId, actions = []) => {
let id = 0;
Expand All @@ -33,7 +34,7 @@ const findUserChampion = (cellId, actions = []) => {

for(const action of actions) {
for(const cell of action) {
if (cell.actorCellId === cellId && cell.type === 'pick') {
if (cell.actorCellId === cellId && GameTypes.includes(cell.type)) {
id = cell.championId;
break;
}
Expand Down Expand Up @@ -70,11 +71,14 @@ const App = () => {

const { actions = [], myTeam = []} = await lcuIns.getCurrentSession();
const member = _find(myTeam, i => i.summonerId > 0) || {};
const { cellId } = member;
let championId = 0;
const { cellId, championId: mChampionId } = member;
let championId;

if (!actions.length && myTeam.length && member) {
// special mode
const isRandomMode = !actions.length && myTeam.length > 0 && mChampionId > 0;
const isVoteMode = mChampionId > 0 && myTeam.length > 0 && myTeam.every(i => i.championId === mChampionId);

console.log(`special mode: `, isRandomMode, isVoteMode)
if (isRandomMode || isVoteMode) { // special mode
championId = member.championId;
} else {
// classic mode
Expand Down

0 comments on commit 95e5b0c

Please sign in to comment.