mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-12 18:53:55 +01:00
fix contract
This commit is contained in:
parent
b7e07bc7f2
commit
3df298e91e
4
dist/engine.bundle.js
vendored
4
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/engineStyle.bundle.js
vendored
2
dist/engineStyle.bundle.js
vendored
@ -1,2 +1,2 @@
|
|||||||
!function(n){function t(t){for(var e,i,f=t[0],c=t[1],l=t[2],a=0,s=[];a<f.length;a++)i=f[a],Object.prototype.hasOwnProperty.call(u,i)&&u[i]&&s.push(u[i][0]),u[i]=0;for(e in c)Object.prototype.hasOwnProperty.call(c,e)&&(n[e]=c[e]);for(p&&p(t);s.length;)s.shift()();return r.push.apply(r,l||[]),o()}function o(){for(var n,t=0;t<r.length;t++){for(var o=r[t],e=!0,f=1;f<o.length;f++){var c=o[f];0!==u[c]&&(e=!1)}e&&(r.splice(t--,1),n=i(i.s=o[0]))}return n}var e={},u={2:0},r=[];function i(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=n,i.c=e,i.d=function(n,t,o){i.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},i.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},i.t=function(n,t){if(1&t&&(n=i(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var e in n)i.d(o,e,function(t){return n[t]}.bind(null,e));return o},i.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return i.d(t,"a",t),t},i.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},i.p="";var f=window.webpackJsonp=window.webpackJsonp||[],c=f.push.bind(f);f.push=t,f=f.slice();for(var l=0;l<f.length;l++)t(f[l]);var p=c;r.push([903,0]),o()}({903:function(n,t,o){"use strict";o.r(t);o(904),o(906),o(908),o(910),o(912),o(914),o(916),o(918),o(920),o(922),o(924),o(926),o(928),o(930),o(932),o(934),o(936),o(938),o(940),o(942),o(944),o(946),o(948),o(950),o(952),o(954),o(956),o(958),o(960),o(962),o(964),o(966)},906:function(n,t,o){},908:function(n,t,o){},910:function(n,t,o){},912:function(n,t,o){},914:function(n,t,o){},916:function(n,t,o){},918:function(n,t,o){},920:function(n,t,o){},922:function(n,t,o){},924:function(n,t,o){},926:function(n,t,o){},928:function(n,t,o){},930:function(n,t,o){},932:function(n,t,o){},934:function(n,t,o){},936:function(n,t,o){},938:function(n,t,o){},940:function(n,t,o){},942:function(n,t,o){},944:function(n,t,o){},946:function(n,t,o){},948:function(n,t,o){},950:function(n,t,o){},952:function(n,t,o){},954:function(n,t,o){},956:function(n,t,o){},958:function(n,t,o){},960:function(n,t,o){},962:function(n,t,o){},964:function(n,t,o){},966:function(n,t,o){}});
|
!function(n){function t(t){for(var e,i,f=t[0],c=t[1],l=t[2],a=0,s=[];a<f.length;a++)i=f[a],Object.prototype.hasOwnProperty.call(u,i)&&u[i]&&s.push(u[i][0]),u[i]=0;for(e in c)Object.prototype.hasOwnProperty.call(c,e)&&(n[e]=c[e]);for(p&&p(t);s.length;)s.shift()();return r.push.apply(r,l||[]),o()}function o(){for(var n,t=0;t<r.length;t++){for(var o=r[t],e=!0,f=1;f<o.length;f++){var c=o[f];0!==u[c]&&(e=!1)}e&&(r.splice(t--,1),n=i(i.s=o[0]))}return n}var e={},u={2:0},r=[];function i(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=n,i.c=e,i.d=function(n,t,o){i.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},i.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},i.t=function(n,t){if(1&t&&(n=i(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var e in n)i.d(o,e,function(t){return n[t]}.bind(null,e));return o},i.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return i.d(t,"a",t),t},i.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},i.p="";var f=window.webpackJsonp=window.webpackJsonp||[],c=f.push.bind(f);f.push=t,f=f.slice();for(var l=0;l<f.length;l++)t(f[l]);var p=c;r.push([904,0]),o()}({904:function(n,t,o){"use strict";o.r(t);o(905),o(907),o(909),o(911),o(913),o(915),o(917),o(919),o(921),o(923),o(925),o(927),o(929),o(931),o(933),o(935),o(937),o(939),o(941),o(943),o(945),o(947),o(949),o(951),o(953),o(955),o(957),o(959),o(961),o(963),o(965),o(967)},907:function(n,t,o){},909:function(n,t,o){},911:function(n,t,o){},913:function(n,t,o){},915:function(n,t,o){},917:function(n,t,o){},919:function(n,t,o){},921:function(n,t,o){},923:function(n,t,o){},925:function(n,t,o){},927:function(n,t,o){},929:function(n,t,o){},931:function(n,t,o){},933:function(n,t,o){},935:function(n,t,o){},937:function(n,t,o){},939:function(n,t,o){},941:function(n,t,o){},943:function(n,t,o){},945:function(n,t,o){},947:function(n,t,o){},949:function(n,t,o){},951:function(n,t,o){},953:function(n,t,o){},955:function(n,t,o){},957:function(n,t,o){},959:function(n,t,o){},961:function(n,t,o){},963:function(n,t,o){},965:function(n,t,o){},967:function(n,t,o){}});
|
||||||
//# sourceMappingURL=engineStyle.bundle.js.map
|
//# sourceMappingURL=engineStyle.bundle.js.map
|
30
dist/vendor.bundle.js
vendored
30
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -168,7 +168,10 @@ export class CodingContract {
|
|||||||
async prompt(): Promise<CodingContractResult> {
|
async prompt(): Promise<CodingContractResult> {
|
||||||
const popupId = `coding-contract-prompt-popup-${this.fn}`;
|
const popupId = `coding-contract-prompt-popup-${this.fn}`;
|
||||||
return new Promise<CodingContractResult>((resolve) => {
|
return new Promise<CodingContractResult>((resolve) => {
|
||||||
createPopup(popupId, CodingContractPopup, {
|
createPopup(
|
||||||
|
popupId,
|
||||||
|
CodingContractPopup,
|
||||||
|
{
|
||||||
c: this,
|
c: this,
|
||||||
popupId: popupId,
|
popupId: popupId,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
@ -176,6 +179,7 @@ export class CodingContract {
|
|||||||
removePopup(popupId);
|
removePopup(popupId);
|
||||||
},
|
},
|
||||||
onAttempt: (val: string) => {
|
onAttempt: (val: string) => {
|
||||||
|
console.error("attempting");
|
||||||
if (this.isSolution(val)) {
|
if (this.isSolution(val)) {
|
||||||
resolve(CodingContractResult.Success);
|
resolve(CodingContractResult.Success);
|
||||||
} else {
|
} else {
|
||||||
@ -183,7 +187,9 @@ export class CodingContract {
|
|||||||
}
|
}
|
||||||
removePopup(popupId);
|
removePopup(popupId);
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
() => resolve(CodingContractResult.Cancelled),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ $(document).keydown(function (event) {
|
|||||||
// Terminal
|
// Terminal
|
||||||
if (routing.isOn(Page.Terminal)) {
|
if (routing.isOn(Page.Terminal)) {
|
||||||
var terminalInput = document.getElementById("terminal-input-text-box");
|
var terminalInput = document.getElementById("terminal-input-text-box");
|
||||||
if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {
|
if (terminalInput != null && !event.ctrlKey && !event.shiftKey && !Terminal.contractOpen) {
|
||||||
terminalInput.focus();
|
terminalInput.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ $(document).keydown(function (e) {
|
|||||||
terminalCtrlPressed = true;
|
terminalCtrlPressed = true;
|
||||||
} else if (e.shiftKey) {
|
} else if (e.shiftKey) {
|
||||||
shiftKeyPressed = true;
|
shiftKeyPressed = true;
|
||||||
} else if (terminalCtrlPressed || shiftKeyPressed) {
|
} else if (terminalCtrlPressed || shiftKeyPressed || Terminal.contractOpen) {
|
||||||
// Don't focus
|
// Don't focus
|
||||||
} else {
|
} else {
|
||||||
var inputTextBox = document.getElementById("terminal-input-text-box");
|
var inputTextBox = document.getElementById("terminal-input-text-box");
|
||||||
@ -338,6 +338,9 @@ let Terminal = {
|
|||||||
commandHistory: [],
|
commandHistory: [],
|
||||||
commandHistoryIndex: 0,
|
commandHistoryIndex: 0,
|
||||||
|
|
||||||
|
// True if a Coding Contract prompt is opened
|
||||||
|
contractOpen: false,
|
||||||
|
|
||||||
// Full Path of current directory
|
// Full Path of current directory
|
||||||
// Excludes the trailing forward slash
|
// Excludes the trailing forward slash
|
||||||
currDir: "/",
|
currDir: "/",
|
||||||
@ -2571,12 +2574,18 @@ let Terminal = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
runContract: async function (contractName) {
|
runContract: async function (contractName) {
|
||||||
|
// There's already an opened contract
|
||||||
|
if (Terminal.contractOpen) {
|
||||||
|
return post("ERROR: There's already a Coding Contract in Progress");
|
||||||
|
}
|
||||||
|
|
||||||
const serv = Player.getCurrentServer();
|
const serv = Player.getCurrentServer();
|
||||||
const contract = serv.getContract(contractName);
|
const contract = serv.getContract(contractName);
|
||||||
if (contract == null) {
|
if (contract == null) {
|
||||||
return post("ERROR: No such contract");
|
return post("ERROR: No such contract");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Terminal.contractOpen = true;
|
||||||
const res = await contract.prompt();
|
const res = await contract.prompt();
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
@ -2603,6 +2612,7 @@ let Terminal = {
|
|||||||
post("Contract cancelled");
|
post("Contract cancelled");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Terminal.contractOpen = false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import { KEY } from "../../../utils/helpers/keyCodes";
|
|||||||
|
|
||||||
import { CodingContract, CodingContractType, CodingContractTypes } from "../../CodingContracts";
|
import { CodingContract, CodingContractType, CodingContractTypes } from "../../CodingContracts";
|
||||||
import { ClickableTag, CopyableText } from "./CopyableText";
|
import { ClickableTag, CopyableText } from "./CopyableText";
|
||||||
import { PopupCloseButton } from "./PopupCloseButton";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
c: CodingContract;
|
c: CodingContract;
|
||||||
@ -28,9 +27,6 @@ export function CodingContractPopup(props: IProps): React.ReactElement {
|
|||||||
if (event.keyCode === KEY.ENTER && value !== "") {
|
if (event.keyCode === KEY.ENTER && value !== "") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
props.onAttempt(answer);
|
props.onAttempt(answer);
|
||||||
} else if (event.keyCode === KEY.ESC) {
|
|
||||||
event.preventDefault();
|
|
||||||
props.onClose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +55,9 @@ export function CodingContractPopup(props: IProps): React.ReactElement {
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
/>
|
/>
|
||||||
<PopupCloseButton popup={props.popupId} onClose={() => props.onAttempt(answer)} text={"Solve"} />
|
<button className={"std-button"} onClick={() => props.onAttempt(answer)}>
|
||||||
<PopupCloseButton popup={props.popupId} onClose={props.onClose} text={"Close"} />
|
Solve
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ interface IProps<T> {
|
|||||||
content: (props: T) => React.ReactElement;
|
content: (props: T) => React.ReactElement;
|
||||||
id: string;
|
id: string;
|
||||||
props: T;
|
props: T;
|
||||||
removePopup: (id: string) => void;
|
removePopup: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Popup<T>(props: IProps<T>): React.ReactElement {
|
export function Popup<T>(props: IProps<T>): React.ReactElement {
|
||||||
function keyDown(event: KeyboardEvent): void {
|
function keyDown(event: KeyboardEvent): void {
|
||||||
if (event.key === "Escape") props.removePopup(props.id);
|
if (event.key === "Escape") props.removePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -39,15 +39,17 @@ export function createPopup<T>(
|
|||||||
id: string,
|
id: string,
|
||||||
rootComponent: (props: T) => React.ReactElement,
|
rootComponent: (props: T) => React.ReactElement,
|
||||||
props: T,
|
props: T,
|
||||||
|
onClose?: () => void,
|
||||||
): HTMLElement | null {
|
): HTMLElement | null {
|
||||||
let container = document.getElementById(id);
|
let container = document.getElementById(id);
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
function onClick(this: HTMLElement, event: MouseEvent): any {
|
function onClick(this: HTMLElement, event: MouseEvent): void {
|
||||||
if (!event.srcElement) return;
|
if (!event.srcElement) return;
|
||||||
if (!(event.srcElement instanceof HTMLElement)) return;
|
if (!(event.srcElement instanceof HTMLElement)) return;
|
||||||
const clickedId = (event.srcElement as HTMLElement).id;
|
const clickedId = (event.srcElement as HTMLElement).id;
|
||||||
if (clickedId !== id) return;
|
if (clickedId !== id) return;
|
||||||
removePopup(id);
|
removePopup(id);
|
||||||
|
if (onClose) onClose();
|
||||||
}
|
}
|
||||||
const backgroundColor = deepestPopupId === "" ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)";
|
const backgroundColor = deepestPopupId === "" ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)";
|
||||||
container = createElement("div", {
|
container = createElement("div", {
|
||||||
@ -62,7 +64,18 @@ export function createPopup<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deepestPopupId === "") deepestPopupId = id;
|
if (deepestPopupId === "") deepestPopupId = id;
|
||||||
ReactDOM.render(<Popup content={rootComponent} id={id} props={props} removePopup={removePopup} />, container);
|
ReactDOM.render(
|
||||||
|
<Popup
|
||||||
|
content={rootComponent}
|
||||||
|
id={id}
|
||||||
|
props={props}
|
||||||
|
removePopup={() => {
|
||||||
|
removePopup(id);
|
||||||
|
if (onClose) onClose();
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
container,
|
||||||
|
);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user