How to use replayPath method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

slpRename.js

Source:slpRename.js Github

copy

Full Screen

1const { SlippiGame } = require('@slippi/slippi-js');2const fs = require('fs');3const path = require('path');4const hash = require('object-hash');5fs.readFile(`${path.dirname(process.execPath) + path.sep}options.txt`, 'utf8', (err, data) => { // Opens options.txt6 if (err) {7 console.error(err);8 return;9 }10 const splitData = data.split(/\r?\n/); // Splits the .txt file into each line for reading11 const userSettings = {};12 splitData.forEach((line) => {13 if (line.includes(':') && !(line.startsWith('#'))) {14 const front = line.split(':')[0];15 const back = line.split(':')[1];16 userSettings[front] = back.trim();17 }18 });19 let replayPath = userSettings['Replay Path (blank for current folder)']; // Sets the replay path from the input in options.txt20 if (replayPath === '') { // If path is empty, set path to the current directory of the program21 replayPath = path.dirname(process.execPath) + path.sep;22 } else {23 replayPath = path.dirname(replayPath) + path.sep + path.basename(replayPath) + path.sep;24 }25 // Setting config options/formats26 const format1v1 = userSettings['Non-Teams Replay Format'].replace('.slp', '');27 const formatTeams = userSettings['Teams Replay Format'].replace('.slp', '');28 const condenseCharBool = (userSettings['Replace Doubles (true/false)'].toLocaleLowerCase().substring(0, 4) === 'true');29 const verbose = (userSettings['Verbose output (true/false)'].toLocaleLowerCase().substring(0, 4) === 'true');30 const condenseChar = userSettings['Character to replace ("space" for space character)'].replace('space', ' ').substring(0, 1);31 const sortBool = (userSettings['Sort into tag folders (true/false)'].toLocaleLowerCase().substring(0, 4) === 'true');32 let idData = {};33 // Load the json ID data34 fs.readFile(path.join(__dirname, path.sep, 'slpids.json'), 'utf8', (jsonErr, jsonData) => {35 if (jsonErr) {36 console.error(`Error reading file from disk: ${jsonErr}`);37 } else {38 idData = JSON.parse(jsonData);39 console.log('\x1b[35m', `FFA Format: \r${format1v1}`);40 console.log(`Teams format: \r${formatTeams}`);41 console.log(`Character condense: ${condenseCharBool}, char: '${condenseChar}'`);42 console.log(`Verbose: ${verbose}`, '\x1b[0m');43 let filesCounter = 0;44 fs.readdir(replayPath, (err1, files) => {45 console.log(`Reading ${replayPath}`);46 if (err1) {47 console.error('Replay directory could not be found', err1);48 process.exit(1);49 }50 console.log('Renaming...');51 files.forEach((file) => {52 const slpPath = `${replayPath}${file}`;53 if (path.extname(slpPath) === '.slp' && !path.basename(slpPath).startsWith('.')) {54 const game = new SlippiGame(slpPath);55 const settings = game.getSettings();56 const metadata = game.getMetadata();57 const matchData = {};58 if (settings === null) {59 console.log('\x1b[31m', `File: ${file} could not be parsed.`, '\x1b[0m');60 return;61 }62 let generalFormat = path.basename(slpPath);63 // General64 if (!(metadata === null)) {65 const nameMinutes = Math.floor((metadata.lastFrame + 120) / 60 / 60);66 const nameSeconds = Math.floor(((metadata.lastFrame + 120) / 60) - nameMinutes * 60);67 matchData['{{GameMinutes}}'] = nameMinutes;68 matchData['{{GameSeconds}}'] = nameSeconds;69 matchData['{{ConsoleNick}}'] = metadata.consoleNick;70 const date1 = new Date(metadata.startAt);71 matchData['{{Date}}'] = metadata.startAt.split('T')[0];72 matchData['{{Year}}'] = date1.getFullYear();73 matchData['{{Month}}'] = date1[Symbol.toPrimitive]('string').split(' ')[1];74 matchData['{{MonthNum}}'] = parseInt(date1.getMonth(), 10) + 1;75 matchData['{{Day}}'] = date1.getDate();76 matchData['{{DayName}}'] = date1[Symbol.toPrimitive]('string').split(' ')[0];77 matchData['{{Time}}'] = newReplaceAll(metadata.startAt.split('T')[1], ':', '꞉').substring(0, 5);78 matchData['{{TimeHours}}'] = date1.getHours();79 matchData['{{TimeMinutes}}'] = date1.getMinutes();80 matchData['{{TimeSeconds}}'] = date1.getSeconds();81 matchData['{{Platform}}'] = metadata.playedOn;82 }83 matchData['{{Stage}}'] = stageSelect(idData, settings.stageId, false);84 matchData['{{StageShort}}'] = stageSelect(idData, settings.stageId, true);85 // Non-Teams86 if ((!settings.isTeams) || (settings.isTeams && settings.players.length === 2)) {87 matchData['{{P1Char}}'] = charSelect(idData, settings.players[0].characterId, false); // Player 188 matchData['{{P1CharShort}}'] = charSelect(idData, settings.players[0].characterId, true);89 matchData['{{P1OfflineTag}}'] = newReplaceAll(settings.players[0].nametag, '?', '?');90 matchData['{{P1ConnectCode}}'] = newReplaceAll(settings.players[0].connectCode, '?', '?');91 matchData['{{P1DisplayName}}'] = newReplaceAll(settings.players[0].displayName, '?', '?');92 matchData['{{P1Color}}'] = costumeSelect(idData, settings.players[0].characterId, settings.players[0].characterColor);93 matchData['{{P2Char}}'] = charSelect(idData, settings.players[1].characterId, false); // Player 294 matchData['{{P2CharShort}}'] = charSelect(idData, settings.players[1].characterId, true);95 matchData['{{P2OfflineTag}}'] = newReplaceAll(settings.players[1].nametag, '?', '?');96 matchData['{{P2ConnectCode}}'] = newReplaceAll(settings.players[1].connectCode, '?', '?');97 matchData['{{P2DisplayName}}'] = newReplaceAll(settings.players[1].displayName, '?', '?');98 matchData['{{P2Color}}'] = costumeSelect(idData, settings.players[1].characterId, settings.players[1].characterColor);99 if (settings.players.length > 2) {100 matchData['{{P3Char}}'] = charSelect(idData, settings.players[2].characterId, false); // Player 3101 matchData['{{P3CharShort}}'] = charSelect(idData, settings.players[2].characterId, true);102 matchData['{{P3OfflineTag}}'] = newReplaceAll(settings.players[2].nametag, '?', '?');103 matchData['{{P3ConnectCode}}'] = newReplaceAll(settings.players[2].connectCode, '?', '?');104 matchData['{{P3DisplayName}}'] = newReplaceAll(settings.players[2].displayName, '?', '?');105 matchData['{{P3Color}}'] = costumeSelect(idData, settings.players[2].characterId, settings.players[2].characterColor);106 }107 if (settings.players.length > 3) {108 matchData['{{P3Char}}'] = charSelect(idData, settings.players[3].characterId, false); // Player 4109 matchData['{{P3CharShort}}'] = charSelect(idData, settings.players[3].characterId, true);110 matchData['{{P3OfflineTag}}'] = newReplaceAll(settings.players[3].nametag, '?', '?');111 matchData['{{P3ConnectCode}}'] = newReplaceAll(settings.players[3].connectCode, '?', '?');112 matchData['{{P3DisplayName}}'] = newReplaceAll(settings.players[3].displayName, '?', '?');113 matchData['{{P3Color}}'] = costumeSelect(idData, settings.players[3].characterId, settings.players[3].characterColor);114 }115 generalFormat = format1v1;116 } else if (settings.isTeams && settings.players.length === 4) {117 let { players } = settings;118 players = players.sort((a, b) => ((a.teamId > b.teamId) ? 1 : -1));119 if (players[0].teamId === players[2].teamId) return;120 matchData['{{T1Color}}'] = ['Red', 'Blue', 'Green'][players[0].teamId];121 matchData['{{T2Color}}'] = ['Red', 'Blue', 'Green'][players[2].teamId];122 matchData['{{T1P1Char}}'] = charSelect(idData, players[0].characterId, false); // Player 1123 matchData['{{T1P1CharShort}}'] = charSelect(idData, players[0].characterId, true);124 matchData['{{T1P1OfflineTag}}'] = newReplaceAll(players[0].nametag, '?', '?');125 matchData['{{T1P1ConnectCode}}'] = newReplaceAll(players[0].connectCode, '?', '?');126 matchData['{{T1P1DisplayName}}'] = newReplaceAll(players[0].displayName, '?', '?');127 matchData['{{T1P1Color}}'] = costumeSelect(idData, players[0].characterId, players[0].characterColor);128 matchData['{{T2P1Char}}'] = charSelect(idData, players[2].characterId, false); // Player 3129 matchData['{{TP1CharShort}}'] = charSelect(idData, players[2].characterId, true);130 matchData['{{T2P1OfflineTag}}'] = newReplaceAll(players[2].nametag, '?', '?');131 matchData['{{T2P1ConnectCode}}'] = newReplaceAll(players[2].connectCode, '?', '?');132 matchData['{{T2P1DisplayName}}'] = newReplaceAll(players[2].displayName, '?', '?');133 matchData['{{T2P1Color}}'] = costumeSelect(idData, players[2].characterId, players[2].characterColor);134 matchData['{{T1P2Char}}'] = charSelect(idData, players[1].characterId, false); // Player 2135 matchData['{{T1P2CharShort}}'] = charSelect(idData, players[1].characterId, true);136 matchData['{{T1P2OfflineTag}}'] = newReplaceAll(players[1].nametag, '?', '?');137 matchData['{{T1P2ConnectCode}}'] = newReplaceAll(players[1].connectCode, '?', '?');138 matchData['{{T1P2DisplayName}}'] = newReplaceAll(players[1].displayName, '?', '?');139 matchData['{{T1P2Color}}'] = costumeSelect(idData, players[1].characterId, players[1].characterColor);140 matchData['{{T2P2Char}}'] = charSelect(idData, players[3].characterId, false); // Player 4141 matchData['{{T2P2CharShort}}'] = charSelect(idData, players[3].characterId, true);142 matchData['{{T2P2OfflineTag}}'] = newReplaceAll(players[3].nametag, '?', '?');143 matchData['{{T2P2ConnectCode}}'] = newReplaceAll(players[3].connectCode, '?', '?');144 matchData['{{T2P2DisplayName}}'] = newReplaceAll(players[3].displayName, '?', '?');145 matchData['{{T2P2Color}}'] = costumeSelect(idData, players[3].characterId, players[3].characterColor);146 generalFormat = formatTeams;147 }148 let renamedMatch = '';149 if (condenseCharBool) {150 renamedMatch = `${path.dirname(slpPath) + path.sep + removeRepeatChar(replaceFormatTags(generalFormat, matchData), condenseChar).trim()}.slp`;151 } else {152 renamedMatch = `${path.dirname(slpPath) + path.sep + replaceFormatTags(generalFormat, matchData).trim()}.slp`;153 }154 if (!(slpPath === renamedMatch)) {155 // If a file with the same name already exists, add a hash for a unique identifier156 while (fs.existsSync(renamedMatch)) {157 const key = hash(game);158 renamedMatch = `${path.dirname(renamedMatch) + path.sep + path.basename(renamedMatch).replace('.slp', '')} ${key.substring(0, 15)}.slp`;159 if (verbose) console.log(`Duplicate name, adding a unique identifier: ${key.substring(0, 15)}`);160 }161 fs.rename(slpPath, renamedMatch, (rnErr) => {162 if (rnErr) console.log(rnErr);163 });164 if (verbose) {165 console.log(`Renamed: ${slpPath} to ${renamedMatch}`);166 }167 }168 }169 if (filesCounter % (Math.floor(files.length / 100) + 1) === 0) {170 console.log(`\x1b[33mRename: ${Math.round(100 * (filesCounter / files.length) * 100) / 100}% ${` (${filesCounter})/(${files.length})`}\x1b[0m`);171 }172 // Sorting Replays (trigger on last rename)173 if (files.length <= filesCounter + 1) {174 if (sortBool) {175 console.log('Sorting replays...');176 sortReplays(replayPath, replayPath, verbose);177 }178 }179 filesCounter += 1;180 });181 });182 }183 });184});185/**186 * Replaces { { Tags } } with the data they represent in the format provided.187 * @param {string} format - format including tags.188 * @param {Object} data - object with every tag and it's corresponding data for the current replay.189 * @returns {string} a completed string with all tags replaced with their data.190 */191function replaceFormatTags(format, data) {192 let returnFormat = format.slice();193 Object.keys(data).forEach((key) => {194 if (Object.prototype.hasOwnProperty.call(data, key)) {195 if (typeof (data[key]) === 'undefined') {196 returnFormat = newReplaceAll(returnFormat, key, '');197 } else {198 returnFormat = newReplaceAll(returnFormat, key, data[key]);199 }200 } else {201 returnFormat = newReplaceAll(returnFormat, key, '');202 }203 });204 return removeExtraTags(returnFormat);205}206/**207 * Removes extra { { Tags } } from a string after replacing ones with data.208 * @param {string} input - a string with unwanted tags still in it.209 * @returns {string} a string with all tags removed.210 */211function removeExtraTags(input) {212 if (input.includes('{{') && input.includes('}}')) {213 return removeExtraTags(input.substring(0, input.indexOf('{{')) + input.substring(input.indexOf('}}') + 2));214 }215 return input;216}217/**218 * Replaces all instances of a string with another string in a string.219 * @param {string} input - the full string being acted on.220 * @param {string} replace - a string to be replaced.221 * @param {string} replaceWith - replacement string.222 * @returns {string} a string with all instances of replace replaced223 */224function newReplaceAll(input, replace, replaceWith) {225 if (!(input.includes(replace))) {226 return input;227 }228 return newReplaceAll(input.replace(replace, replaceWith), replace, replaceWith);229}230/**231 * Sorting replays into directories with tags (reused my summit 13 sorting code)232 * @param {string} replayPath233 * @param {string} basePath - same as replaypath, dw about it :)234 * @param {boolean} verbose - verbose output boolean235 */236function sortReplays(replayPath, basePath, verbose) {237 let slpPath = '';238 fs.readdir(replayPath, (err, files) => {239 if (err) {240 console.error('Could not list the directory.', err);241 process.exit(1);242 }243 const tagsList = {};244 console.log('Getting Tags...');245 try {246 fs.mkdirSync(`${basePath}No_Tags`);247 } catch {248 console.error('Please delete /No_Tags/ and try again.');249 }250 files.forEach((file) => {251 const file1 = file;252 slpPath = `${replayPath}${file1}`;253 if (path.extname(slpPath) === '.slp') {254 const game = new SlippiGame(slpPath);255 const settings = game.getSettings();256 const { players } = settings;257 let noTags = true;258 players.forEach((player) => {259 if (player.nametag.length > 0) {260 noTags = false;261 }262 });263 if (noTags) {264 fs.copyFile(slpPath, `${basePath}No_Tags${path.sep}${path.basename(slpPath)}`, (cfErr) => {265 if (cfErr) console.error(cfErr);266 });267 }268 const tags = [];269 settings.players.forEach((player) => {270 if (player.nametag.length > 0) {271 tags.push(player.nametag.replace('?', '?'));272 }273 });274 tags.forEach((tag) => {275 if (Object.prototype.hasOwnProperty.call(tagsList, tag)) {276 tagsList[tag].push(slpPath);277 } else {278 tagsList[tag] = [slpPath];279 }280 });281 }282 });283 console.log('Sorting Files...');284 let sortIndex = 0;285 Object.keys(tagsList).forEach((key, index, array) => {286 if (sortIndex % (Math.floor(index / 100) + 1) === 0) {287 console.log(`\x1b[33mSort: ${Math.round(100 * (sortIndex / array.length) * 100) / 100}% ${` (${index})/(${array.length})`}\x1b[0m`);288 }289 try {290 if (!fs.existsSync(basePath + key)) {291 fs.mkdirSync(basePath + key);292 if (verbose) console.log(`Created directory: "${key}" with ${tagsList[key].length} files. ${path.basename(tagsList[key][0])}`);293 }294 } catch (mkErr) {295 console.error(mkErr);296 }297 sortIndex += 1;298 });299 console.log('Adding files to directories...');300 let addIndex = 0;301 Object.keys(tagsList).forEach((key, index, array) => {302 if (addIndex % (Math.floor(index / 100) + 1) === 0) {303 console.log(`\x1b[33mAdd to dir: ${Math.round(100 * (addIndex / array.length) * 100) / 100}% ${` (${index})/(${array.length})`}\x1b[0m`);304 }305 tagsList[key].forEach((tagsPath) => {306 fs.copyFile(tagsPath, `${basePath + key}/${path.basename(tagsPath)}`, (cfErr) => {307 if (cfErr) console.error(cfErr);308 });309 });310 addIndex += 1;311 });312 });313}314function removeRepeatChar(input, char) {315 let outString = '';316 let prevChar = '';317 for (let i = 0; i < input.length; i += 1) {318 if (input[i] !== char || prevChar !== char) {319 outString += input[i];320 }321 prevChar = input[i];322 }323 return outString;324}325function isObject(obj) {326 return Object.prototype.toString.call(obj) === '[object Object]';327}328/**329 * Turns stage IDs into stage strings based on Fizzi's SLP spec.330 * @param {Object} data - JSON data of IDs and their corresponding stage in Fizzi's spec.331 * @param {number} stage - stage ID.332 * @param {boolean} short - whether to return a short version of the stage name.333 * @returns {string} a stage name based on the given ID.334 */335function stageSelect(data, stage, short) {336 if (Object.prototype.hasOwnProperty.call(data.stage, stage)) {337 if (short) {338 if (isObject(data.stage[stage])) {339 return data.stage[stage].short;340 }341 return data.stage[stage];342 }343 if (isObject(data.stage[stage])) {344 return data.stage[stage].long;345 }346 return data.stage[stage];347 }348 return '';349}350/**351 * Turns character IDs into character strings based on Fizzi's SLP spec.352 * @param {Object} data - JSON data of IDs and their corresponding character in Fizzi's spec.353 * @param {number} char - character id.354 * @param {boolean} short whether to return a short version of the character name.355 * @returns {string} a character name based on the given ID.356 */357function charSelect(data, char, short) {358 if (short) {359 if (isObject(data.character[char])) {360 return data.character[char].short;361 }362 return data.character[char];363 }364 if (isObject(data.character[char])) {365 return data.character[char].long;366 }367 return data.character[char];368}369/**370 * Turns character IDs into costume strings based on Fizzi's SLP spec.371 * @param {Object} data - JSON data of IDs and their corresponding costume in Fizzi's spec.372 * @param {number} char - character ID.373 * @param {boolean} costumeNum - costume ID.374 * @returns {string} - a character name based on the given ID.375 */376function costumeSelect(data, char, costumeNum) {377 if (Object.prototype.hasOwnProperty.call(data.costume, char)) {378 return data.costume[char][costumeNum];379 }380 return '';...

Full Screen

Full Screen

renderer.ts

Source:renderer.ts Github

copy

Full Screen

1// This file is required by the index.html file and will2// be executed in the renderer process for that window.3// All of the Node.js APIs are available in this process.4const { ipcRenderer } = require('electron')5const {dialog} = require('electron').remote;6const fs = require('electron').remote.require('fs')7const Store = require('electron-store');8const store = new Store();9var files: any;10var fileNumber: number = 0;11var leaguePath: string;12var replayPath: string;13var summonerName: string;14var apiKey = 'RGAPI-d0a5ffda-1044-43a5-b325-35f4d52c4e09';15function startReplayProcess() {16 leaguePath = document.getElementById('leaguePath').innerText; 17 replayPath = document.getElementById('replayPath').innerText;18 summonerName = (<HTMLInputElement>document.getElementById('summonerName')).value;19 if (!validateForm()) {20 console.log('invalid form');21 console.log(leaguePath);22 console.log(replayPath);23 console.log(summonerName); 24 return;25 }26 files = fs.readdirSync(replayPath);27 setLeagueConfig();28 storePaths();29 getMatchAndStartLeague();30}31function getMatchAndStartLeague() {32 console.log(summonerName);33 if (fileNumber == files.length) {34 return;35 } 36 let regexp: RegExp = /\-(.*?)\./;37 let matchId:string = regexp.exec(files[fileNumber])[1]38 console.log(matchId);39 fetch(`https://na1.api.riotgames.com/lol/match/v4/matches/${matchId}?api_key=${apiKey}`)40 .then(response => {41 return response.json();42 })43 .then(match => {44 let array:Array<ParticipantIdentity> = match.participantIdentities; 45 let me:any = array.find(x => x.player.summonerName == summonerName);46 console.log(me);47 let participantId = me.participantId;48 49 let participantArray:Array<any> = match.participants; 50 let teamId = participantArray.find(x=> x.participantId == participantId).teamId;51 let teamArray:Array<any> = participantArray.filter(x=>x.teamId == teamId);52 let champions:Array<number> = new Array();53 let userChampion: number;54 for (let i = 0; i < teamArray.length; i++) {55 champions.push(teamArray[i].championId);56 if (teamArray[i].participantId == participantId) {57 userChampion = teamArray[i].championId;58 } 59 } 60 console.log("teamId: " +teamId);61 console.log(champions);62 fetch(`https://na1.api.riotgames.com/lol/match/v4/timelines/by-match/${matchId}?api_key=${apiKey}`)63 .then(result => {64 return result.json();65 })66 .then(timeline => {67 console.log(timeline);68 let eventArray: Array<LeagueEvent> = new Array();69 for (let i = 0; i < timeline.frames.length; i++) {70 for (let j = 0; j < timeline.frames[i].events.length; j++) {71 if (timeline.frames[i].events[j].type == 'CHAMPION_KILL') { 72 eventArray.push(timeline.frames[i].events[j]);73 }74 }75 }76 eventArray = eventArray.filter(x=> x.killerId == participantId);77 let timeEventArray: Array<LeagueEventTime> = new Array();78 eventArray.forEach(element => {79 let time: LeagueEventTime = new LeagueEventTime();80 time.startTime = Math.max(0, element.timestamp/1000 - 15);81 time.endTime = element.timestamp/1000 + 1582 time.timestamp = element.timestamp;83 timeEventArray.push(time); 84 });85 let i = 0;86 //if 2 events would overlap, we combine them87 while(i < timeEventArray.length-1) {88 timeEventArray.sort((a,b)=> (a.startTime, b.startTime) ? 1: -1);89 if (timeEventArray[i].endTime >= timeEventArray[i+1].startTime) {90 timeEventArray[i].endTime = timeEventArray[i+1].endTime;91 timeEventArray.splice(i+1,1); 92 } else { 93 i++;94 }95 }96 console.log(timeEventArray);97 let payload: Payload = new Payload();98 payload.leagueEventTimes = timeEventArray;99 payload.matchId = matchId100 payload.teamId = teamId;101 payload.championIds = champions;102 payload.summonerName = summonerName;103 payload.leaguePath = leaguePath;104 payload.replayPath = replayPath;105 console.log(payload)106 ipcRenderer.send('startReplay', payload);107 })108 }) 109 fileNumber++;110 console.log('next filenumber is: '+fileNumber);111}112ipcRenderer.on('dir-name', (event, payload) => {113 files = payload;114})115ipcRenderer.on('replay-loaded', (event, payload) => {116 console.log('replay loaded!');117})118ipcRenderer.on('next-replay', (event, payload) => {119 getMatchAndStartLeague();120})121ipcRenderer.on('log-event', (event, payload) => {122 console.log(payload);123})124function getParticipant(name: any, match: any) {125 return match.filter(126 function(match: any){return match.summonerName == name }127 );128}129function setInstallPath() {130 document.getElementById('leaguePath').innerText = (<HTMLInputElement>document.getElementById('leagueInstallPath')).files[0].path131}132function setReplayPath() {133 document.getElementById('replayPath').innerText = (<HTMLInputElement>document.getElementById('leagueReplayPath')).files[0].path134}135function clickFileDialog() {136 document.getElementById('leagueInstallPath').click();137}138function clickReplayDialog() {139 document.getElementById('leagueReplayPath').click();140}141function setLeagueConfig() {142 if (!fs.existsSync(leaguePath + '\\Game\\Data\\cfg\\game.cfg')) {143 if (!fs.existsSync(leaguePath + '\\Game\\Data\\cfg')) {144 fs.mkdirSync(leaguePath + '\\Game\\Data\\cfg');145 console.log("copied directory");146 }147 fs.copyFileSync(leaguePath+'\\Config\\game.cfg', leaguePath+'\\Game\\Data\\cfg\\game.cfg');148 console.log("copied file");149 }150 var config:string = fs.readFileSync(leaguePath+'\\Game\\Data\\cfg\\game.cfg', 'utf8');151 if (config.indexOf('EnableReplayApi=1') === -1) {152 var newConfig = config.slice(0, 15) + 'EnableReplayApi=1\n' + config.slice(15);153 fs.writeFileSync(leaguePath+'\\Game\\Data\\cfg\\game.cfg', newConfig);154 } 155}156function validateForm() {157 let valid = true;158 if (!validateInstallPath()) {159 valid = false;160 }161 if (!validateReplayPath()) {162 valid = false;163 }164 if (summonerName.length == 0) {165 valid = false;166 console.log(document.getElementById('summonerName').innerText);167 } 168 return valid;169}170function validateInstallPath() {171 if (!leaguePath) {172 return false;173 }174 return (fs.existsSync(leaguePath + '\\Game\\League of Legends.exe')); 175}176function validateReplayPath() {177 if (!replayPath) {178 return false;179 }180 return fs.readdirSync(replayPath).length > 0;181}182function storePaths() {183 store.set('leagueInstallPath', leaguePath);184 store.set('leagueReplayPath', replayPath);185}186interface Player {187 platformId: string;188 accountId: string;189 summonerName: string;190 summonerId: string;191 currentPlatformId: string;192 currentAccountId: string;193 matchHistoryUri: string;194 profileIcon: number;195}196interface ParticipantIdentity {197 participantId: number;198 player: Player;199}200interface Position {201 x: number;202 y: number;203}204interface LeagueEvent {205 type: string;206 timestamp: number;207 position: Position;208 killerId: number;209 victimId: number;210 assistingParticipantIds: any[];211}212class LeagueEventTime {213 startTime: number;214 endTime: number;215 timestamp: number;216}217class Payload{218 leagueEventTimes: LeagueEventTime[]; 219 matchId: string;220 championIds: number[];221 summonerName: string;222 teamId: number;223 leaguePath: string;224 replayPath: string;...

Full Screen

Full Screen

converter.js

Source:converter.js Github

copy

Full Screen

1'use strict';2// This file reads in input.gior, parses/deserializes it, and writes the result to output.gioreplay.3var fs = require('fs');4var LZString = require('lz-string');5// fs.readFileSync returns a Buffer since we didn't specify an option.6var replayPath = process.argv[2];7var destinationPath = replayPath + 'eplay'; // Concatenate 'eplay' so that the extension becomes '.gioreplay'8var input = fs.readFileSync(replayPath);9// Returns an object that represents the replay.10// @param serialized A serialized replay Buffer.11function deserialize(serialized) {12 var obj = JSON.parse(13 LZString.decompressFromUint8Array(14 new Uint8Array(serialized)15 )16 );17 var replay = {};18 var i = 0;19 replay.version = obj[i++];20 replay.id = obj[i++];21 replay.mapWidth = obj[i++];22 replay.mapHeight = obj[i++];23 replay.usernames = obj[i++];24 replay.stars = obj[i++];25 replay.cities = obj[i++];26 replay.cityArmies = obj[i++]27 replay.generals = obj[i++];28 replay.mountains = obj[i++];29 replay.moves = obj[i++].map(deserializeMove);30 replay.afks = obj[i++].map(deserializeAFK);31 replay.teams = obj[i++];32 replay.map_title = obj[i++]; // only available when version >= 733 return replay;34};35function deserializeMove(serialized) {36 return {37 index: serialized[0],38 start: serialized[1],39 end: serialized[2],40 is50: serialized[3],41 turn: serialized[4],42 };43}44function deserializeAFK(serialized) {45 return {46 index: serialized[0],47 turn: serialized[1],48 };49}50// Write the converted file.51try {52 fs.writeFileSync(destinationPath, JSON.stringify(deserialize(input)));53 console.log('Conversion successful!');54} catch (e) {55 console.error('Failed to write output file', e);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {replayPath} = require('fast-check-monorepo');3replayPath('test3', 1, () => {4 fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => {5 fc.pre(a + b === 0);6 return true;7 }));8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const {replayPath} = require("fast-check-monorepo");3const arbitary = fc.integer(0, 100);4fc.assert(5 fc.property(arbitary, (n) => {6 return n >= 0 && n <= 100;7 }),8 {replayPath: replayPath}9);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const fs = require('fs');3const path = require('path');4const { replayPath } = require('fast-check-monorepo');5const seed = 42;6const pathToPreviousRun = path.join(__dirname, 'test3_path.json');7const previousRun = replayPath(pathToPreviousRun);8const arb = fc.array(fc.integer(-100, 100));9fc.assert(10 fc.property(arb, (xs) => {11 const sum = xs.reduce((a, b) => a + b, 0);12 return sum >= 0;13 }),14 { seed, verbose: 2, ...previousRun }15);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful