整天都在这。我正在建立一个社交网络。 它检查两个用户是否已相互连接,如果他们有这样的结构已创建。 根 - >组 - > RequestingUser-> UserTheyWant
当两个人互相请求时,我想要比较两个变量,所以如果两个变量都是真的,我可以继续。我无法让它发挥作用。
我已经尝试了很多这样的迭代,但我无法从中获得真/假值,我不想发布我的所有尝试......希望这可以解决它。
我只需要两个函数didYouRequest和didTheyRequest返回true / false或者didTheVisitorConnect / checkIfOtherProfilePersonConnected实际设置在该死的函数之外,这样我就可以比较它们。
$scope.connect = () => {
// my userid -> and set key in there for who they want to visit
console.log('added ' + $scope.profile.name + ' as friend.');
return fbGroupsDb.child(userLoggedIn).child(userUID).set(
{
connected: true
});
};
var didTheVisitorConnect = false;
$scope.didTheVisitorConnect = false;
var checkIfOtherProfilePersonConnected = false;
$scope.checkIfOtherProfileConnected = false;
var didYouRequest = fbGroupsDb.child(userLoggedIn).child(userUID).once('value').then( function (snapshot) {
if (snapshot.val() !== null) {
$scope.didTheVisitorConnect = true;
didTheVisitorConnect = true;
console.log('Did You Request? : ', didTheVisitorConnect);
return true;
} else {
$scope.didTheVisitorConnect = false;
didTheVisitorConnect = false;
console.log('Did You Request? : ', didTheVisitorConnect);
return false;
}
});
var didTheyRequest = fbGroupsDb.child(userUID).child(userLoggedIn).once('value').then( function (snapshot) {
if (snapshot.val() !== null) {
$scope.checkIfOtherProfileConnected = true;
checkIfOtherProfilePersonConnected = true;
console.log('Have they requested You? : ', checkIfOtherProfilePersonConnected);
return true;
} else {
$scope.checkIfOtherProfileConnected = false;
checkIfOtherProfilePersonConnected = false;
console.log('Have they requested You? : ', checkIfOtherProfilePersonConnected);
return false;
}
});
答案 0 :(得分:1)
你似乎在寻找
def main():
print("This game is the first created by the G.R.R. Digital Entertainment Division.")
a = input("Welcome to The Forest. It is currently dawn in the middle of a temperate forest. You wake up, unknown of your surroundings. What do you do? ")
if a == 'Go north' or 'Go North':
print("You went North until you came to the border of the forest and a pasture. You see house with smoke coming out of the chimney ahead of you, a creek to your right, a meteor coming in from your left, and a forest behind you.")
elif a == 'Go West' or 'Go west':
pass
elif a == 'Go east' or 'Go East':
pass
elif a == 'Go south' or 'Go South':
pass
elif a == 'Check supplies' or 'Check Supplies':
print("You currently have a Compass, a dagger, a cyanide pill for suicide, a bottle of iodine, clothes, and a fannypack.")
elif a == 'suicide' or 'Suicide':
pass
else:
pass